[5] In 711, a Muslim army commanded by Tariq ibn Ziyad, belonging to the Umayyad Caliphate of Damascus, invaded the Iberian peninsula then controlled in its entirety by the Visigothic Kingdom.
This kingdom gradually expanded across the mountainous north of the Iberian peninsula, capturing Leon and Galicia among other territories and it would be under the aegis of its kings that 146 years later Christian rule would reach the banks of the Douro River, where the city and region of Portucale, now Porto, was located.
During the reign of Alfonso III of Asturias, 157 years after the invasion of the Iberian peninsula by Muslims, the nobleman Vímara Peres seized Porto and its territory, then called Portucale, or Portugal, at a time when the head of royal guard of the Emir of Cordoba had revolted.
[8] Other locations south of the Douro were then taken and resettled by order of Alfonso III of Asturias, such as Viseu, Lamego, and Anégia (Gondomar) where the Chapel of Nossa Senhora da Cividade now stands specifically.
Civil-war broke out in the Caliphate of Cordoba in 1009 and this would ultimately result in the fragmentation of the Andaluz into several independent and rival emirates or taifa states, a circumstance which benefited the Christian kingdoms to the north.
After a pilgrimage to Santiago de Compostela that included the entire royal family, Coimbra was beset on January 20, 1064, and fell to Christian hands on July 9, 1064, after a six-month siege.
Coimbra was attacked in 1117 by the Almoravid emir Ali Ibn Yusuf at the head of a large army which included both Africans as well as Andalucians, "as many as the grains of sand of the sea" according to one source.
Its garrison was tasked not only with defending the access to Coimbra from the south, but also to attack Santarém and its surrounding territory, raiding fields, capturing persons, ambushing caravans until the city was weak enough to be taken by assault.
Dom Paio Guterres was left as alcaide of Leiria and he launched so many successful attacks against the territory of Santarém that in 1137 the castle was assaulted and razed, with over 250 men among knights and footmen being killed.
After the Treaty of Tuy was signed and peace sealed with Emperor Alfonso VII of León, king Afonso Henriques led a major raid in Muslim territory.
[24] Once peace was signed with Emperor Alfonso VII of Leon after the Battle of Valdevez, Afonso Henriques marched south with his men, crossed the Douro river close to Lamego, and routed the Muslims at Trancoso, which he expelt from the territory.
Still in 1165, Geraldo the Fearless took Trujillo and Évora, both in the middle of the night and then offered the latter city to Afonso Henriques, apparently in exchange for a large sum of money, and the king then made him its alcaide.
The host of the Portuguese king arrived at Badajoz and settled within the city, however the defenders still in the high citadel were unexpectedly relieved not by the Almohad Caliph but by the Emperor of León and his army.
[44] A few weeks later in September the prince led a new siege against the now severely weakened Badajoz but the city was once again relieved on time, not just by Leonese forces but by an Almohad army commanded by Abu Hafs Umar ibn Yahya al-Hintati as well.
[47] Upon their return, the place where the relics ought to be deposited caused an upheaval between the mozarabic residents of the parish of Santa Justa, the dean of the Lisbon Cathedral and the Augustinian monks of the Monastery of Saint Vicent.
[47] The chief-frontiersman of Estremadura Gonçalo Viegas de Lanhoso marched down from the castle with a corps of soldiers and only by his armed intervention could order be restored and an agreement reached between all parts, whereby the relics where deposited in the cathedral, though a piece was retained by the monks.
[46][51] Troops gathered in Coimbra in the month of May and they included both infantry and cavalry drawn from the Order of Calatrava, the urban militias of the city as well as various other towns, such as Santarém, Lisbon and Évora, and the hosts of some of the main nobles in Portugal.
[52] Making a wide circuit through the modern Spanish Extremadura, the Portuguese crossed Sierra Morena and reached Seville in November, however their host was insufficient to assault the great city.
[52] The great Triana Raid was one of the most daring military operations conducted in the history of Portugal and allowed the prince Sancho to affirm himself as a worthy commander and heir to the throne.
[51] A major landmark in Portuguese history was achieved in 1179 as by the Papal decree Manifestis Probatum, Portugal was acknowledged as an independent kingdom by the Vatican, largely as a result of the efforts by king Afonso against the Muslims.
The Almohad Caliph Abu Yaqub Yusuf crossed the Strait of Gibraltar at the head of a large army in 1184 and moving through Seville and Badajoz invaded Portugal for the fourth time.
[59] He began by taking the opportunity to focus on organizing the administration of his kingdom, and granted charters regulating the laws and privileges of several Portuguese towns such as Gouveia and Covilhã in 1186, Viseu and Brangança in 1187 and Folgosinho and Valhelhas in 1188.
A new crusader fleet called at Lisbon in 3 or 4 July and on this occasion king Sancho obtained their support for a planned attack against the major city of Silves, the most important one in the Gharb al-Andalus.
The inhabitants surrendered, together with the surrounding castles at Lagos, Alvor, Portimão, Monchique, Santo Estêvão, Carvoeiro, São Bartolomeu de Messines, Paderne e Sagres.
King Sancho of Portugal was at Lisbon at the time and he managed to obtain the support of 500 crusaders to relieve Santarém, hence he turned down the Caliphs peace proposals, which involved relinquishing Silves.
Only king Sancho sent a body of troops to aid Castile, led by the former alcaide of Silves Rodrigo Sanches and master of Calatrava in Portugal Gonçalo Viegas de Lanhoso.
Meanwhile, King Alfonso VIII of Castile launched a new war against the Almohads, after the truce signed with them had expired and Caliph Muhammad Nasser once again gathered a large army and crossed into Iberia.
[89] Once king Afonso III had emerged victorious from the civil war that pitted him against his brother, he crossed the mountains of Algarve in the first weeks of March through Almodôvar, at the head of his royal host.
Official Portuguese participation in the Reconquista came to an end and so did the opportunity to gain territory and spoils, hence many knights and warriors crossed the border to find service under the kings of Leon and Castile as adventurers or mercenaries.
In 1340 the Marinid sultan of Morocco Abu Hasan Ali invaded mainland Iberia with a large army in cooperation with the emir of Granada Yusuf I, however they were repulsed by a joint Portuguese and Castillian force at the Battle of River Salado.