Spain has of borders, with 5 countries.
Borders
Spain–Portugal border
The Spain-Portugal border, commonly known as La Raya, is 1,292 kilometers long. It extends through the provinces of Pontevedra, Ourense, Zamora, Salamanca, Cáceres, Badajoz and Huelva in Spain, and the districts of Viana do Castelo, Braga, Vila Real, Bragança, Guarda, Castelo Branco, Portalegre, Évora, Beja, Faro in Portugal.
The border starts in the mouth of Minho River, and ends in the mouth of Guadiana River.
Spain-France border
The Spain-France border is 656.3 km long. It is divided in two parts, since it is interrupted by Andorra. The first part extends through the provinces of Gipuzkoa, Navarre, Huesca, Lleida and Girona in Spain, and the departments of Pyrénées-Atlantiques, Hautes-Pyrénées, Haute-Garonne, Ariège, Pyrénées-Orientales in France.
The border goes from the mouth of Bidasoa River to a cape between Cerbère and Portbou, and crosses the Pyrenees.
Spain–Andorra border
The Spain-Andorra border is 63.7 km long. It extends through the province of Lérida in Spain, and the parishes of La Massana, Andorra La Vella, Sant Julià de Lòria, Escaldes-Engordany and Encamp.
This border is a hotspot for smuggling, because of the cheapness of tobacco in Andorra.
Spain–Morocco border
The autonomous cities of Ceuta and Melilla, and the Peñón de Vélez de la Gomera make the border with Morocco, which is 19 km long.
The borders of Ceuta and Melilla, are de facto, because between them and Morocco there is no man's land. The only real border would be the 27 meters long one in the Peñón de Vélez de la Gomera.
Spain–Gibraltar border
The Spain–Gibraltar border is 1.2 km long and connects the British Overseas Territory of Gibraltar and the Spanish municipality of La Línea de la Concepción.