At São Mamede, outside Guimarães, the young Afonso Henriques and the Portuguese barons defeated his mother Teresa and her Galician allies — the founding battle of Portuguese autonomy.
The battle of São Mamede, fought on 24 June 1128 on the field below Guimarães castle, is conventionally the founding act of Portugal: the moment the county's native baronage, behind the nineteen-year-old Afonso Henriques, took its government away from his mother Teresa and her Galician allies of the house of Traba.
It was a small battle with a continental consequence. Nothing in 1128 said the winner would wear a crown; but the party that won was precisely the party defined by Portuguese autonomy — against Galician magnates, against Leonese overlordship, against the county's absorption into anyone else's politics — and its leader spent the next forty years turning that programme into a kingdom.
Teresa's regency had drifted, in her son's partisans' eyes, into a Galician captivity: Fernando Pérez de Traba held the county's great strongholds, Galician clients held its honores, and the county's future seemed mortgaged to a trans-Minho aristocratic bloc. The young Afonso — knighted by his own hand at Zamora in 1125, in the emperor's old fashion — became the standard around which the barons of Entre-Douro-e-Minho and the see of Braga gathered.
The breach turned military in 1127–1128. Alfonso VII of León-Castile, Teresa's nephew, besieged Guimarães itself to enforce his overlordship — tradition has the young Afonso's tutor Egas Moniz pledging homage to raise the siege — and when the Leonese pressure lifted, the internal question remained: mother's party or son's. The armies met at midsummer on São Mamede field.
No detailed contemporary account of the fighting survives; the chronicles record the essential result. Afonso's barons broke the comital army, Teresa and Fernando Pérez fled north of the Minho, and by tradition the countess was briefly held before her expulsion. Guimarães, the cradle-fortress of the county, passed definitively to the son.
Afonso dated his rule from the victory, governing as infans and duke of the Portuguese. The programme São Mamede had crowned unfolded across the next two decades: victory over the Muslims at Ourique in 1139 and the royal title with it, the treaty of Zamora with León in 1143, and the conquest of Lisbon in 1147. The field below Guimarães kept its place in Portuguese memory as the spot where, as the town's later motto has it, Portugal was born.