Morocco has a coast by the Atlantic Ocean that reaches past the Strait of Gibraltar into the Mediterranean Sea.
It is bordered by Spain to the north (a water border through the Strait and land borders with three small Spanish-controlled exclaves, Ceuta, Melilla, and Penon de Velez de la Gomera), Algeria to the east and Western Sahara to the south.
Since Morocco controls most of Western Sahara, its de facto southern boundary is with Mauritania.
The internationally recognised borders of the country lie between latitudes 27° and 36°N, and longitudes 1° and 14°W.
Adding Western Sahara, Morocco lies mostly between 21° and 36°N, and 1° and 17°W (the Ras Nouadhibou peninsula is slightly south of 21° and west of 17°).
The geography of Morocco spans from the Atlantic Ocean, to mountainous areas, to the Sahara desert. Morocco is a Northern African country, bordering the North Atlantic Ocean and the Mediterranean Sea, between Algeria and the annexed Western Sahara.
It is one of only three nations (along with Spain and France) to have both Atlantic and Mediterranean coastlines.
A large part of Morocco is mountainous. The Atlas Mountains are located mainly in the centre and the south of the country. The Rif Mountains are located in the north of the country. Both ranges are mainly inhabited by the Berber people.
At 446,550 km2 (172,414 sq mi), Morocco is the fifty-seventh largest country in the world. Algeria borders Morocco to the east and southeast, though the border between the two countries has been closed since 1994.
Spanish territory in North Africa neighbouring Morocco comprises five enclaves on the Mediterranean coast: Ceuta, Melilla, Penon de Velez de la Gomera, Penon de Alhucemas, the Chafarinas islands, and the disputed islet Perejil.
Off the Atlantic coast the Canary Islands belong to Spain, whereas Madeira to the north is Portuguese. To the north, Morocco is bordered by the Strait of Gibraltar, where international shipping has unimpeded transit passage between the Atlantic and Mediterranean.
The Rif Mountains stretch over the region bordering the Mediterranean from the north-west to the north-east. The Atlas Mountains run down the backbone of the country, from the northeast to the south west.
Most of the southeast portion of the country is in the Sahara Desert and as such is generally sparsely populated and unproductive economically. Most of the population lives to the north of these mountains, while to the south lies the Western Sahara, a former Spanish colony that was annexed by Morocco in 1975 (see Green March).
Morocco claims that the Western Sahara is part of its territory and refers to that as its Southern Provinces.
Morocco’s capital city is Rabat; its largest city is its main port, Casablanca. Other cities recording a population over 500,000 in the 2014 Moroccan census are Fes, Marrakesh, Meknes, Salé and Tangier.
Morocco is represented in the ISO 3166-1 alpha-2 geographical encoding standard by the symbol MA. This code was used as the basis for Morocco’s internet domain, .ma.