Gharb al-Andalus
After a small civil war in the already Christianized Visigothic Kingdom in Hispania, King Roderic ("Rodrigo" in Portuguese and Spanish) had a strong position in the peninsula. His opponents, exiled in Ceuta, asked Musa ibn Nusair, Umayyad Muslim governor and general, for help. The initially skeptical general sent an experimental expedition mainly consisting of Moors from North and West Africa, led by Tariq ibn Ziyad, thus initiating the Muslim conquest of Iberia. Tariq utterly defeated Roderic's Visigothic army in the Battle of Guadalete, and soon after captured Toledo and Córdoba. With Tariq's success, Musa joined the expedition and established himself as governor of the new territories. By 714 Évora, Santarém and Coimbra had been conquered, and two years later Lisbon was in Muslim control. By 718 most of today's Portuguese territory was under Umayyad rule. The Umayyads eventually stopped between Poitiers and Tours but Muslim rule in Iberia would last until 1492 with the fall of the Kingdom of Granada. The Emirate of Córdoba lasted from 756 to 929. The Caliphate of Córdoba lasted from 929 to 1031. It was followed by the Taifas. The first Taifa of Badajoz, ruled by the Aftasid dynasty, existed from 1009 to 1094. The Taifa of Lisbon lasted from 1022 to 1034, when it as annexed to Taifa of Badajoz. Lisbon was ruled by Alfonso VI of León and Castile between 1093 and 1094. The first Taifa of Mértola lasted from 1033 to 1044, when it became part of the Taifa of Seville. The Taifa of Santa Maria do Algarve lasted from 1018 to 1051, when it became part of the Taifa of Seville. The first Taifa of Silves lasted from 1040 to 1063, when it became part of the Taifa of Seville. The Taifa of Santarém lasted from 1144 to 1145, when it became part of the Taifa of Badajoz. The Almoravid dynasty lasted from 1040 to 1147. During some of that time it ruled over what is now Southern Portugal. After a successful siege, Portugal gained control of Lisbon in 1147. There were three taifas in what is now Portugal after the fall of the Almoravid dynasty: the second Taifa of Mértola, which lasted from 1144 to 1151, the second Taifa of Silves, which lasted from 1144 to 1151 and the Taifa of Tavira which lasted from 1146 to 1150. All three taifas became part of the Almohad Caliphate in 1151. The Almohad Caliphate lasted from 1121 to 1269. During much of this time, until 1249, it ruled much of what is now southern Portugal. Eventually, however, a taifa based at Niebla was founded in the last years of 1230s and controlled the region up to 1249, when the Kingdom of Portugal conquered Faro.
Umayyad Conquest
This period started with the fall of the Visigothic kingdom after Tariq ibn-Ziyad's invasion of Iberia and the establishment of the Umayyad control in the territory.