The foreign relations of Spain could be constructed upon the foreign relations of the Hispanic Crown. The personal union of Castile and Aragon that ensued with the joint rule of the Catholic Monarchs was followed by the annexation of the Kingdom of Granada and the Kingdom of Navarre. The crown also built a large colonial empire in the Americas after the arrival of Columbus to the New World in 1492.

The Spanish Habsburg monarchs had large holdings across the European continent stemming from the inherited dominions of the Habsburg monarchy and from the Aragonese holdings in the Italian Peninsula. The Habsburg dynasty fought against the Protestant Reformation in the continent and achieved a dynastic unification of the realms of the Iberian Peninsula with their enthronement as Portuguese monarchs after 1580. The American colonies shipped bullion, but resources were spent in wars waged against France in Italy and elsewhere as well as in conflicts against the Ottoman Empire, England or revolts in the Spanish Netherlands, Portugal (lost after 1640) and Catalonia (lost in 1640 and recovered after 1652). Mainland Spain was the main theatre of the War of Spanish Succession (1701–1714), after which the Bourbon dynasty consolidated rule, while handing in holdings in Italy and the Netherlands. The successive Bourbon Family Compacts underpinned a close alignment with the Kingdom of France throughout the 18th century. During the Napoleonic Wars, Mainland Spain was occupied by the French Empire (which installed a puppet ruler), and became after an 1808 uprising the main theatre of the Peninsular War. Nearly all its colonies fought for and won independence in the early 19th century. From then on it kept Cuba, Puerto Rico and the Philippines, otherwise lost in 1898 after the Spanish–American War, and, in line with far-reaching efforts by other European powers, Spain began to sustain a colonial presence in the African continent, most notably in Western Sahara and Equatorial Guinea. It also intervened in Nguyễn Vietnam alongside France and involved in the affairs of former colony Santo Domingo, which briefly returned to Spanish control from 1861 to 1865. In the wake of the creation of a Spanish protectorate in Northern Morocco, the early 20th century saw a draining conflict against Riffian anti-colonial resistance. Spain stuck to a status of neutrality during World War I.

The Spanish Civil War of 1936–1939 became a proxy war between the axis powers Germany and Italy and the Soviet Union (which lost). The war ensued with the installment of a dictatorship under Francisco Franco lasting until 1975. In the aftermath of World War 2, the series of multilateral agreements and institutions configuring what it is known today as Western Europe were made apart from Francoist Spain. The 1953 military agreements with the United States entailed the acceptance of unprecedented conditions vis-à-vis the (peacetime) military installment of a foreign power on Spanish soil. Spain joined the UN in 1955 and the IMF in 1958. In the last rales of the dictator, the mismanaged decolonisation of Spanish Sahara ensued with the Moroccan invasion of the territory in 1975 and the purported partition of it between Morocco and Mauritania, spawning a protracted conflict pitting the Sahrawi national liberation Polisario Front against Morocco and (briefly) Mauritania lasting to this day. Spain joined NATO (1982) and entered the European Communities (1986).

On a wide range of issues, Spain often prefers to coordinate its efforts with its EU partners through the European political cooperation mechanisms. In addition to being represented via EU membership, Spain is a permanently invited guest to all G20 summits.

History In 218 BC the Romans invaded the Iberian Peninsula, which later became the Roman province of Hispania. The Romans introduced the Latin language, the ancestor of both modern-day Spanish and Italian. The Iberian peninsula remained under Roman rule for over 600 years, until the collapse of the Western Roman Empire.

In the Early modern period, until the 18th century, southern and insular Italy came under Spanish control, having been previously a domain of the Crown of Aragon.

Habsburg Spain In contrast with the purely Mediterranean focused foreign policy of the Catholic kings, during Habsburg Spain era, the foreign policy of the Spanish Empire turned more continental and was defined by the support to the Habsburg monarchy in its patrimonial conflicts and participation in the Religious wars in Europe, specially the Holy Roman Empire's struggles against the Ottomans, the German Protestants and the French–Austrian rivalry. During the Spanish Golden Age, the main objectives of its foreign policy were:

The consolidation of Spanish/Iberian influence in the Mediterranean (Italian Peninsula and Maghreb) and Western-Central Europe (Netherlands-Burgundy and Habsburg Austria) against the Franco-Ottoman alliance, and in Oversea (Americas and Philippines) against English, Dutch and Portuguese colonialists. The expelling of the Ottomans from the Balkans with the help of Safavid Iran, Poland-Lithuania and Eastern Catholic dissidency (being considered the conquests of former Aragonese territories and the Holy Land), liberating the Patriarch of Constantinople from the Sultan and supporting the reunification between Catholic and Orthodox Churches. Support the Council of Trent dispositions and goals about the Re-Catholicisation of the States of the Holy Roman Empire, England and Scandinavia to restore the unity among the Res publica Christiana in Western civilisation according to Counter-Reformation. Also oppose to French Gallicanism and Raison d'Stat, in favour of Ultramontan and Universitas christiana's views to lead the Christendom . Evangelisate the New World, East Asia and Africa into Catholicism, with the special help of the Franciscans and Jesuits (which had a lot of pro-Spanish influence through the House of Loyola). Secure the Tordesillas' Iberian monopoly and rights against hostile European or Local Great Powers (which included to support Portugal against Muslims or Pagans). Being considered possible conquests in Ming China, Moluccas, Sulawesi, Cambodia, Borneo, Siam, Japan, Oceanian realm, Kongo, Ethiopia, Safavid Iran, North America, among others (or at least to turn them into allies and develop trade routes). The restoration of the Roman Empire through supporting the consolidation of the HRE as an Unified and Universal monarchy under Spanish patronage or leadership (only with Charles V), with possible pretensions of World domination through an association with the Iberian Union oversea empire.

Charles V

Charles V (1500–1558) inherited vast lands across Western Europe and the Americas, and expanded them by frequent wars.Geoffrey Parker, Emperor: A New Life of Charles V (2019) excerpt Among other domains he was King of Spain from 1516, and Holy Roman Emperor and Archduke of Austria from 1519. As head of the rising House of Habsburg during the first half of the 16th century, his dominions in Europe extending from Germany to northern Italy with direct rule over the Austrian hereditary lands and the Burgundian Low Countries, and a unified Spain with its southern Italian kingdoms of Naples, Sicily, and Sardinia.

Charles V imperial ideology was based in the Universal monarchy, with influences from Dante Alighieri and Erasmus' Christian humanism, which supported Ghibelline Political theory that given the Universal power firstly to the Monarch and then to the Pope. This provoked an initial conflict between the HRE and the Papal States, as a continuation of the medieval dispute over Dominium mundi in which Spain took the side of the Empire over the Church (opposing to the Political theology of the Doctrine of Two Swords). This initial bad reputation of regalist and cripto-heretic, added to his foreign origins, provocated the initial resistance of Spaniards to join to the Charles V Empire. After the reconciliation of the HRE and Spain with the Papacy, Spain take a relevant position as the dominant power of the imperial project, overcoming the Kingdom of Germany (divided by the Protestant Reform) in the protagonism of Charles V's foreign policy (but at the cost of the resignation of Mercurino di Gattinara, main ideologue, from the Spanish Cortes).

His great enemy on land was France, on the Mediterranean Sea it was the Ottoman Empire, which at times was allied with France. England and the Papacy were sometimes part of the coalition against him. Much of his attention focused on wars in Italy. At the Diet of Augsburg (1547) he secured recognition that the Netherlands belonged to the Hapsburg domain. However Charles was intensely Catholic and the northern Netherlands was Protestant. He and his Spanish heirs fought for a century against Dutch independence; despite the enormous cost they failed.Karl Brandi, The Emperor Charles V: the growth and destiny of a man and of a world-empire (1971) online

The Anti-Islamic foreign policy was perceived as a continuation of the Reconquista, in which the main objective of Spain was the continuation of such campaign until conquering the former Roman Tingitana (modern Morocco), which was politically linked to the former Roman Hispania. Another goal was reconquering all Early Muslim conquests for the Christendom (inspired in the Crusading movement) which would end in the deposition of the Ottoman Caliphate after a crossing of North Africa and the Balkans to the Holy Land by a Holy League of all Europe led by Spain and a Habsburg–Persian alliance in a total victory. However, due to the French–Habsburg rivalry across Europe making division and debiliting Habsburg Austria, such ambitious project of a great anti-Ottoman coalition never materialized. So, the Realpolitik turned into a Spanish–Ottoman struggle for the domination over the Mediterranean Sea, specially the attempts to conquer the Barbary states and the constant defense of the Italian states from Ottoman raids.

In Oversea, Charles foreign policy was determinated by the Carreira de Indias global rivalry with the Portuguese Empire (specially in the Indonesian Archipelago and in Colonial Brazil), having to renounce some expansionist projects (like the claims of Spain over the Spice islands after the Treaty of Zaragoza) for the sake of having good relations with the Kingdom of Portugal.

Philip II, 1556–1598

During Philip II, Spain developed a big compromise as the main promotor of Catholic Counter-Reformation among Europe, defining an imperial ideology according to the teachings of the Council of Trent and Traditionalist Catholicism. Spanish foreign policy during the reign of Philip II was developed in two phases. In phase 1, between the 1560s and early 1570s, priority was given to the defense of the Mediterranean and the rivalry with the Ottoman Empire, which was resolved in favor of the Christian forces after the victory at Lepanto. In phase 2, between the late 1570s to 1590s, priority was given to consolidating Spanish control in the Atlantic and the expansion of Catholicism in the New World and the Indies (while also reacting against Protestant expansion in Western Europe).

The Anti-Islamic foreign policy of Philip II led to support a greater integration of the Italian states for the development of an Espionage system through the Spain–Turkey diplomatic envoys (being important the Ragusa Republic as an intermediary), wanting to instigate anti-Ottoman revolts in Albania or Greece and coup d'etats to the Sublime Porte, while reactivating the Habsburg–Persian alliance, to prepare the possible collapse of the Turks in the Ottoman–Venetian War (1570–1573). However the Venetian focus in its own interests in the Stato da Màr, instead of an Universitas Christianna perspective, disbanded the Holy League of 1571.