Its location has made Ceuta an important commercial trade and military way-point for many cultures, beginning with the Carthaginians in the 5th century BC, who called the city Abyla. It was not until the Romans took control of the region in A.D. 42 that the port city, then named Septa, assumed an almost exclusive military purpose. It changed hands again approximately 400 years later, when Vandal tribes ousted the Romans. It then fell into the hands of the Visigoths, and finally become an outpost of the Byzantine Empire.
Around 710, as Muslim armies approached the city, its Byzantine governor, Julian (described as King of the Ghomara) changed his allegiance, and exhorted the Muslims to invade the Iberian Peninsula. Under the leadership of Berber General Tariq ibn Ziyad, the Muslims used Ceuta as a staging ground for an assault on Visigothic Spain. After Julian's death, the Arabs took direct control of the city, something that the indigenous Berber tribes resented. They destroyed Ceuta during the Kharijite rebellion led by Maysara al-Haqir in 740.
Ceuta lay in ruins until it was resettled in the 9th century by Mâjakas, chief of the Majkasa Berber tribe, who started the short-lived Banu Isam dynasty. His great-grandson would briefly ally his tribe with the Idrisids, but the Banu Isam rule ended in 931 when he abdicated in favor of the Umayyad Caliph of Cordoba, Abd ar-Rahman III. Ceuta reverted to Hispanic Andalusian rule in 927, along with Melilla, and laterTangier, in 951.
Chaos ensued with the fall of the Umayyad caliphate in 1031, but eventually Ceuta and the rest of Muslim Spain fell into the hands of successive North African dynasties. Starting in 1084, the Almoravid Berbers ruled the region until 1147, when the Almohads who conquered the land and ruled, apart from Ibn Hud's rebellion of 1232, until theTunisian Hafsids established their control. The Hafsids' influence in the west rapidly waned, and Ceuta´s inhabitants eventually expelled them in 1249. After this, a period of political instability persisted, under competing interests from the Kingdom of Fez and the Kingdom of Granada. The Kingdom of Fez finally conquered the region in 1387, with assistance from the Crown of Aragon.
In 1415, during the Battle of Ceuta, the city was captured by the Portuguese during the reign of John I of Portugal. The King of Spain seized the Portuguese throne in 1580 and held it for 60 years ( Iberian Union ). During this time Ceuta gained many residents of Spanish origin. Thus Ceuta became the only city of the Portuguese Empire that sided with Spain when Portugal regained its independence in 1640 and war broke out between the two countries.
The formal allegiance of Ceuta to Spain was recognized by the Treaty of Lisbon by which, on January 1, 1668, King Afonso VI of Portugal formally ceded Ceuta to Carlos II of Spain. However, the originally Portuguese flag and coat of arms of Ceuta remained unchanged and the modern-day Ceuta flag features the configuration of the Portuguese shield. The flag's background is also the same as that of the flag of Lisbon.
When Spain recognized the independence of Spanish Morocco in 1956, Ceuta and the other plazas de soberanía remained under Spanish rule as they were considered integral parts of the Spanish state - which Morocco strongly disputed. Culturally, modern Ceuta is part of the Spanish region of Andalusia. Indeed, it was attached to the province of Cádiz until 1925 — the Spanish coast being only 20 km away. It is a cosmopolitan city, with a large ethnic Berber Muslim minority as well as Sephardic Jewish and Hindu minorities.
On November 5, 2007, King Juan Carlos I visited the city, sparking great enthusiasm from the local population and protests from the Moroccan government. It was the first time a Spanish head of state had visited Ceuta in 80 years.
Ceuta (and Melilla) have declared the Muslim holiday of Eid al-Adha or Feast of the Sacrifice, as an official public holiday from 2010 onwards. It is the first time a non-Christian religious festival is officially celebrated in Spain since the Reconquista.
The Catholic Diocese of Ceuta existed from 1417 to 1879. It was a suffragan of the Patriarchate of Lisbon until 1675, with the end of the Iberian Union, when Ceuta chose to remain linked to the king of Spain. Since then it was a suffragan of the archbishopric of Seville. The Diocese of Tanger was suppressed and incorporated to that of Ceuta in 1570.
In 1851, upon the signature of the concordat between the Holy See and Spain, the diocese of Ceuta was agreed to be suppressed, being combined into the diocese of Cádiz y Ceuta (up to then diocese of Cádiz y Algeciras), whose bishop usually was the apostolic administrator of Ceuta. The agreement was not implemented until 1879.