Spain is part of Europe.
The European Union ( EU ) is a political and economic union of member states that are located primarily in Europe . Madrid ( [ məˈdrɪd ] , [ maˈðɾið ] , [ maˈðɾi ] ) is the capital city of the Kingdom of Spain and the largest municipality in both the Community of Madrid and Spain as a whole . Spain . It is the only European country to have a border with an African country ( Morocco ) and its African territory accounts for nearly 5 % of its population , mostly in the Canary Islands but also in Ceuta and Melilla . With an area of 505990 km2 , Spain is the largest country in Southern Europe , the second largest country in Western Europe and the European Union , and the fourth largest country in the European continent .