Morocco borders three territories by land — Algeria to the east and southeast, Mauritania to the south, and Spain through its two enclaves of Ceuta and Melilla on the Mediterranean coast. Together these frontiers stretch for roughly 2,362 kilometres, wrapping Morocco's eastern and southern flanks while the Atlantic Ocean and the Mediterranean Sea define the rest of its outline.
What makes Morocco's neighbourhood unusual is that one of its land borders is with a European country. The enclaves of Ceuta and Melilla make Spain Morocco's only land frontier in Europe and the only place where the European Union shares a continental border with mainland Africa.
Algeria: The Longest and Most Complicated Border
Algeria is by far Morocco's largest neighbour and shares its longest land boundary, running for well over 1,500 kilometres from the Mediterranean coast down through the Atlas ranges and into the Sahara. The two nations share deep linguistic, religious, and cultural ties, with Arabic and Berber spoken on both sides and a long history of intertwined trade routes.
Despite this closeness, the border has been officially closed since 1994. Tensions over the Western Sahara dispute, in which Algeria backs the Polisario Front, have kept the crossing shut for decades. The frontier remains one of the longest closed land borders in the world, and travellers cannot pass directly between the two countries by road.
Mauritania: The Southern Desert Frontier
To the south, Morocco's boundary with Mauritania runs through the sparsely populated reaches of the Sahara. Much of this border lies along the contested territory of Western Sahara, which Morocco administers and considers part of its sovereign land, though its status remains disputed internationally.
The main link between the two countries is the crossing near Guerguerat, a strategic corridor on the route between Morocco and West Africa. This stretch of road is one of the busiest trade arteries between North and sub-Saharan Africa, carrying goods, trucks, and travellers heading toward Nouakchott and beyond. The surrounding landscape is harsh and arid, dominated by sand, rock, and long empty horizons.
Spain: A European Border in Africa
Spain's presence on the African mainland gives Morocco its most distinctive frontier. The autonomous cities of Ceuta and Melilla sit on the Mediterranean coast, fully surrounded by Moroccan territory yet governed from Madrid. Both have been Spanish for centuries — Melilla since 1497 and Ceuta since the 1500s — and Morocco continues to claim them.
These enclaves are ringed by tall border fences and serve as the EU's only land gateway from Africa, making them focal points for migration, customs control, and cross-border commerce. Thousands of Moroccans living nearby once crossed daily to work or trade, and the cities blend Spanish architecture and language with a strong North African character.
The Strait of Gibraltar and Maritime Neighbours
Beyond its land borders, Morocco faces Europe across a narrow band of water. The Strait of Gibraltar separates Morocco from mainland Spain and is only about 14.3 kilometres wide at its narrowest point, where the Mediterranean meets the Atlantic. On a clear day the Spanish coast is visible from Moroccan beaches near Tangier.
This proximity makes Spain a maritime neighbour as well as a land one, and ferries shuttle constantly between Tangier and ports such as Tarifa and Algeciras. Portugal also lies across the Atlantic to the northwest, sharing maritime space with Morocco. The strait has been one of the world's most important shipping chokepoints for millennia, linking the Mediterranean trading world with the open ocean.
Why Morocco's Borders Matter
Morocco's position at the meeting point of Africa and Europe has shaped its history, economy, and identity. Its frontiers reflect Phoenician, Roman, Arab, Berber, and European influences layered over thousands of years. Today those borders govern everything from migration policy and tourism to the flow of agricultural exports, phosphates, and manufactured goods. For a fuller picture of the country itself, see our morocco country guide.
- Morocco shares land borders with three territories: Algeria, Mauritania, and Spain (Ceuta and Melilla).
- Total land border length is approximately 2,362 km.
- The Algeria border has been closed since 1994.
- The Strait of Gibraltar is just 14.3 km wide at its narrowest.
Frequently Asked Questions
How many countries border Morocco?
Morocco shares land borders with three: Algeria, Mauritania, and Spain via the enclaves of Ceuta and Melilla. It is the only African country with a land border with a European Union member.
Is the Morocco–Algeria border open?
No. The land border between Morocco and Algeria has been closed since 1994 because of political tensions, including the dispute over Western Sahara. Travellers cannot cross directly between the two countries by road.
How far is Morocco from Spain?
At its closest, Morocco is only about 14.3 kilometres from mainland Spain across the Strait of Gibraltar. Ferries regularly cross between Tangier and the Spanish ports of Tarifa and Algeciras in under an hour.
Does Morocco border the ocean?
Yes. Morocco has a long Atlantic Ocean coastline to the west and a Mediterranean Sea coastline to the north, giving it one of the longest shorelines in Africa alongside its three land frontiers.
