Lagos is an ancient maritime town with more than 2,000 years of history. The name Lagos has a Celtic origin and is derived from the word Lacobriga. Lagos first became a settlement of the Carthaginians,who recruited Celtic tribesmen in their war against the Romans (the Punic Wars). Later it became colonized by the Romans, becoming part of the Roman province Lusitania. Some Roman remains can still be found in Lagos and the surrounding countryside. Quintus Sertorius, a Roman rebellious general, helped by the Lusitanians of Lacobriga, fought successfully a battle against the Roman army of Q. Caecilius Metellus Pius probably at nearby Monte Molićo. Lacobriga was already in those times an important harbour.
The town was occupied in the sixth century by the Visigoths from the Kingdom of Toledo and later by the Byzantines. The Moors came in the eight century. The renamed the town Zawaia (meaning Lago = lake). It was part of the coastal region al-Gharb (hence the name Algarve). The Moors fortified the town and established important trade links. In 1174 the local Wali gave permission for the construction of a church of St. John the Baptist outside the town walls. This is the oldest church in the Algarve.
Even as King Afonso Henriques was reconquering Portugal (the Reconquista), the southern part (Algarve and Alentejo) remained under Moorish domination. It was captured by King Afonso III of Portugal in 1241. After the complete capture of Algarve in 1249 the king gave himself the title "King of Portugal and Algarve", stressing the fact that the Algarve, after the long rule by the Moors, was considered a foreign country and not part of Portugal.
Lagos became an independent jurisdiction under the rule of King Pedro I in 1361. King Joćo I assembled his fleet in the harbour of Lagos, before setting sail for the siege and conquest of the city of Ceuta in 1415. This was the first step in opening the Arabian world to medieval Europe, which in fact led to the Age of Discovery with Portuguese explorers sailing across the whole world.