section_path: History/Independence
section_name: Independence
paragraph_text: Independence
  
  At the Battle of São Mamede, in the outskirts of Guimarães, in 1128, Afonso Henriques, Count of Portugal, defeated his mother Countess Teresa and her lover Fernão Peres de Trava, establishing himself as sole leader of the county. Afonso continued his father Henry of Burgundy's Reconquista wars. His campaigns were successful and in 1139, he obtained a victory in the Battle of Ourique, so was proclaimed King of Portugal by his soldiers. This is traditionally taken as the occasion when the County of Portugal became the independent Kingdom of Portugal and, in 1129, the capital city was transferred from Guimarães to Coimbra. Afonso was recognized as the first king of Portugal in 1143 by King Alfonso VII of León, and in 1179 by Pope Alexander III as Afonso I of Portugal, with the papal bull Manifestis Probatum.
  
  Afonso Henriques and his successors, aided by military monastic orders, continued pushing southwards against the Moors. In 1217, during the reign of King Afonso II, Portuguese troops, supported by crusaders and others, retook Alcácer do Sal, with further land conquests from the Moors during the reign of Sancho II, mainly the start of the conquest of the Algarve in 1238. After internal tensions, Sancho II was deposed from the throne and his brother, Afonso III, became king in 1248. A year later, in 1249, the Reconquista ended with the capture of the Algarve, in the aftermath of the Siege of Faro, and the last Moorish settlements were expelled. With minor readjustments, Portugal's territorial borders have remained the same, making it one of the oldest established nations in Europe.
  
  After a conflict with the kingdom of Castile, Denis of Portugal signed the Treaty of Alcañices in 1297 with Ferdinand IV of Castile. This treaty established the border between the kingdoms of Portugal and Leon. During the reign of Denis, the first university in Portugal opened in Lisbon, on March 1st 1290, being then transferred to Coimbra in 1308. Denis died in 1325 and was succeeded by his son, Afonso IV, who had a strained relationship with his father that nearly ended in war. In 1355, in the aftermath of the assassination of Inês de Castro, Peter's I lover, a civil war broke between the King, Afonso IV, and his son, and heir, Peter, with peace only being achieved in 1357. The reigns of Denis, Afonso IV, and Peter I mostly saw peace with the other kingdoms of Iberia.
  
  In 1348-49 Portugal, as with the rest of Europe, was devastated by the Black Death. In 1373, Portugal, during the reign of Ferdinand I, made an alliance with England, the oldest standing alliance in the world. This alliance was signed during the Fernandine Wars, a series of conflicts between Portugal and Castile over the right to the throne of Castile. This alliance would be reinforced with the signing of the Treaty of Windsor in 1386.