The son of King Edward (Duarte) and Queen Leonor, daughter of King Ferdinand I of Aragon, Afonso succeeded to the throne at the age of six. In 1440 his mother was deprived of the regency by his uncle Pedro, Duke de Coimbra, whose daughter Isabella Afonso married. The regent was in turn challenged by a half brother, the Duke de Bragança, and was forced to fight, dying at Alfarrobeira (May 1449). Afonso remained considerably under the influence of others, and he distributed his favours rashly. In North Africa he conquered Alcácer Ceguer in 1458, failed to take Tangier in 1463, took Arzila in 1471, and finally took Tangier.

A widower, he married the young daughter of Henry IV of Castile and espoused her cause against Isabella and Ferdinand. Although he assumed the title of king of Castile, he was defeated at Toro in 1476. He then sailed for France, hoping to enlist the aid of Louis XI. This was refused, and he informed his son (later King John II) that he would abdicate and become a hermit in France. He was persuaded to return to Portugal in November 1477, but he renounced his reign and signed the Treaty of Alcáçovas (1479) abandoning any claim to Castile. He died before the Cortes could meet to ratify his abdication.