The first king of Portugal fought which Muslim inhabitants of the Maghreb?
Afonso I of Portugal Afonso I (1106/ 25 July 1109 /11116 December 1185), nicknamed "the Conqueror" (Portuguese: "O Conquistador" ), "the Founder" ("O Fundador" ) or "the Great" ("O Grande" ) by the Portuguese, and "El-Bortukali" [in Arabic البرتقالي] ("the Portuguese") and "Ibn-Arrink" [in Arabic ابن الرَّنك or ابن الرَنْق] ("son of Henry", "Henriques") by the Moors whom he fought, was the first King of Portugal. He achieved the independence of the southern part of the Kingdom of Galicia, the County of Portugal, from Galicia's overlord, the King of León, in 1139, establishing a new kingdom and doubling its area with the "Reconquista", an objective that he pursued until his death, in 1185, after forty-six years of wars against the Moors.
Fernando Pérez de Traba Fernando (or Fernán) Pérez de Traba ("c".1090–1 November 1155), also Fernão Peres de Trava (] or ] ) in Portuguese, was a nobleman and count of the Kingdom of León who for a time held power over all Galicia. He became the lover of Countess Teresa of Portugal, through whom he attained great influence in that domain, and was the "de facto" ruler of the County of Portugal between 1121 and 1128. The "Poema de Almería", a Latin poem celebrating one of Alfonso VII's major victories of the "Reconquista", records that "if one were to see him [Fernán], one would judge him already a king."