Occupying the greater part of the Iberian Peninsula, Spain is the third-largest country in Europe, with an area of 504,782 sq km (194,897 sq mi). Comparatively, the area occupied by Spain is slightly more than twice the size of the state of Oregon. This total includes the Balearic Islands (Islas Baleares) in the western Mediterranean Sea and the Canary Islands (Islas Canarias) in the Atlantic Ocean west of Morocco; both island groups are regarded as integral parts of metropolitan Spain. The Spanish mainland extends 1,085 km (674 mi) E – W and 950 km (590 mi) N – S . Bordered by the Bay of Biscay, France, and Andorra on the N , by the Mediterranean on the E and S , by Gibraltar and the Strait of Gibraltar on the S , by the Gulf of Cádiz on the SW , and by Portugal and the Atlantic on the W , Spain has a total land boundary of 1,918 km (1,192 mi) and a coastline of 4,964 km (3,084 mi). Spain also holds Ceuta, Melilla, and other "places of sovereignty" in the north of Morocco.
Spain has long claimed Gibraltar, a narrow peninsula on the south coast, which was taken by a British-Dutch fleet in 1704 and became a British colony under the Treaty of Utrecht (1713). Spain closed the border with Gibraltar in 1969. In 1980, agreement was reached with Britain to begin negotiations concerning Gibraltar's sovereignty; the border was opened to pedestrian traffic in December 1982 and fully reopened in February 1985. Talks between the United Kingdom and Spain were held in February and December 1985 and January 1987.
Spain's capital city, Madrid, is located in the center of the country.