Afonso IV (ɐˈfõsu; 8 February 1291 - 28 May 1357), called the Brave (o Bravo), was King of Portugal from 1325 until his death in 1357. He was the only legitimate son of King Denis of Portugal and Elizabeth of Aragon.
Afonso, born in Lisbon, was the rightful heir to the Portuguese throne. However, he was not Denis' favourite son, the old king preferring his illegitimate son, Afonso Sanches. The notorious rivalry between the half brothers led to civil war several times. On 7 January 1325, Afonso IV's father died and he became king, whereupon he exiled his rival, Afonso Sanches, to Castile, and stripped him of all the lands and fiefdom given by their father. From Castile, Afonso Sanches orchestrated a series of attempts to usurp the crown. After a few failed attempts at invasion, the brothers signed a peace treaty, arranged by Afonso IV's mother, Elizabeth.
In 1309, Afonso married Beatrice of Castile, daughter of King Sancho IV of Castile and María de Molina. The first-born of this union was a daughter, Maria of Portugal.
In 1325 Alfonso XI of Castile entered a child-marriage with Constanza Manuel of Castile, the daughter of one of his regents. Two years later, he had the marriage annulled so he could marry Afonso's daughter, Maria of Portugal. Maria became Queen of Castile in 1328 upon her marriage to Alfonso XI, who soon became involved publicly with a mistress. Constanza was imprisoned in a castle in Toro while her father, Don Juan Manuel, waged war against Alfonso XI until 1329. Eventually, the two reached a peaceful accord after mediation by Juan del Campo, Bishop of Oviedo; this secured Constanza's release from prison.
The public humiliation of his daughter led Afonso IV to have his son and heir, Peter I of Portugal, marry the no less aggrieved Castilian infanta, Constanza. Afonso subsequently started a war against Castile, peace arriving four years later, through the intervention of the infanta Maria herself. A year after the peace treaty was signed in Seville, Portuguese troops played an important role in defeating the Moors at the Battle of Río Salado in October 1340.