Spain is a sovereign state and a member state of the European Union. It is located on the Iberian Peninsula in southwestern Europe. Its mainland is bordered to the south and east by the Mediterranean Sea except for a small land boundary with Gibraltar; to the north and north east by France, Andorra, and the Bay of Biscay; and to the west and northwest by Portugal and the Atlantic Ocean. It is one of three countries (Morocco, France) to have both Atlantic and Mediterranean coastlines. Spain's 1,214 km (754 mi) border with Portugal is the longest uninterrupted border within the European Union.
Spanish territory also includes the Balearic Islands in the Mediterranean, the Canary Islands in the Atlantic Ocean off the African coast, and two autonomous cities in North Africa, Ceuta and Melilla, that border Morocco, plus Alborán, Chafarinas Islands, Alhucemas, Vélez de la Gomera and other small islets including Perejil. Furthermore, the town of Llívia is a Spanish exclave situated inside French territory. With an area of 505,992 km2 , Spain is the second largest country in Western Europe and the European Union, and the fifth largest country in Europe