Geographically, Gibraltar is attached to Spain. Politically, it is a self governing Overseas Territory of the United Kingdom.
strait of Gibraltar
The Strait of Gibraltar separates Spain from Africa
Morocco
The country that sits at the Strait of Gibraltar is Spain. The strait serves as a natural boundary between Spain in Europe and Morocco in Africa, connecting the Atlantic Ocean to the Mediterranean Sea. The British Overseas Territory of Gibraltar is also located at the northern entrance of the strait.
North of the Strait of Gibraltar is in Europe, not in Africa so the nearest country is Spain. South of the Strait, the nearest country is Morocco, which is in Africa.
The Strait of Gibraltar connects the Atlantic Ocean to the Mediterranean Sea and separates Spain from Morocco.
Morocco
Spain
Morocco is the African country separated from Europe by the Strait of Gibraltar, which connects the Atlantic Ocean to the Mediterranean Sea.
The Strait of Gibraltar
Tangier, is a Moroccan seaport that is located on the strait of Gibraltar.
Spain is north of the strait while Morocco is south.