Iberian federalism, pan-Iberism or simply Iberism (Aragonese, Basque, Galician, Portuguese and Spanish: Iberismo; Asturian: Iberismu; Catalan and Occitan: Iberisme) are the names for the pan-nationalist ideology supporting a unification of all the territories of the Iberian Peninsula. It is mostly used to refer to Portugal and Spain but may also encompass Andorra, Gibraltar and territories of France such as Northern Catalonia or the French Basque Country.
Portugal and Spain share a common history to some degree. Spanish and Portuguese are both Romance languages like Catalan, Galician, Asturleonese and Aragonese, all spoken in the Iberian peninsula.
The Portuguese language and Galician languages evolved from the medieval Galician-Portuguese when the County of Portugal separated from the Kingdom of León by becoming the Kingdom of Portugal. On the other hand, the Galician language has become increasingly influenced by the Castilian language since Galicia's incorporation into the Crown of Castile as a dependent Kingdom of León.
The identities of both modern Spain and Portugal developed during the experience of the Reconquista. In 1512, Ferdinand II of Aragon conquered the Kingdom of Navarre bringing the territories of what would become known as modern Spain under a common ruler. However Portugal remained an independent kingdom, competing with Spain (Castile) in colonial expansion. To avoid conflict, the Treaty of Tordesillas divided the world into Portuguese and Castilian hemispheres of influence.
As a result of the disappearance of Sebastian I of Portugal at the Battle of Alcácer Quibir, Philip II of Spain exerted his dynastic rights and used Castilian troops to overcome the rival pretender. The national poet of Portugal Luís de Camões opposed Philip, but had himself written some sonnets in Spanish (bilingualism was then common in both courts).
In 1581, Philip became Philip I of Portugal, joining both crowns into the most extended empire in history up to that time. The Spanish Habsburgs (Philip III of Spain and II of Portugal, Philip IV of Spain and III of Portugal) ruled what has later been called the Iberian Union, a personal union of different kingdoms, including Portugal (with its colonies), Castile (with its colonies), and Aragon. In 1640, the duke of Bragança gathered those restless in Portugal with the support of Cardinal Richelieu of France. His rebellion succeeded and he became the John IV of Portugal. The North African city of Ceuta decided to leave the crown of Portugal and remain under the Spanish king.
In 1801, the Portuguese city of Olivença was occupied by Spain and passed to Spanish sovereignty as Olivenza. Portugal has never made a formal claim to the territory after the Treaty of Vienna decided that Spain should terminate its occupation of the city, which Spain ignored nor has it acknowledged the Spanish sovereignty over Olivenza. There is no common definition of the border in the area.
It was José Marchena who, in the 18th century, gave this doctrine a progressive, federal and republican tone in l'Avis aux espagnols. In the Liberal Triennium (1820–1823), the secret liberal organizations tried to spread Iberism in Portugal, to create seven confederated republics, five in Spain and Lusitania Ulterior and Lusitania Citerior in Portugal.
In the later Revolutionary Sexennium, the movement reached its apogee; General Prim was also in favour of uniting the two countries. After his murder, the First Spanish Republic (1873–1874) seemed the right moment for the union given its federalism.
In the point of view of the 19th century conservative restorations in Spain and Portugal, the "iberisms" played the role of agents of social change with republican and revolutionary stances, thus threatening the stability of the peninsular nations.
In the 20th century, Iberism melted into the ideologies of some leftist currents such as the anarchist Federación Anarquista Ibérica and the Federación Ibérica de Juventudes Libertarias.
The nationalistic dictatorships of Portugal and Francoist Spain shared many political similarities and some degree of mutual support but both countries were said to live "back to back".
Currently no party represented in either country's parliament has the goal of Iberism but both countries joined the European Economic Community in 1986 and their borders and those of all other countries signing the Schengen accord have been opened since then. The Spanish party Izquierda Republicana has defended 'Iberian Federalism' as political structure for the state.
Large companies have opened shop in the neighbouring country, and the Portuguese state closed the birth center of the border municipality of Elvas, sending patients to the Extremadura health system. Some groups defend Iberism, including some Spanish and Portuguese officers. One 2006 survey by an Angolan weekly newspaper Sol  showed only 28% of the Portuguese think that Portugal and Spain should be one country. 42% of these would put the capital in Madrid and about the same, 41%, in Lisbon.
A 2009 poll found 30.3% of Spanish respondents would support a federation and 39.9% of Portuguese respondents would support one. The figures rose to 31 and 45 percent, respectively, in 2010.
A poll conducted by the Spanish University of Salamanca in 2011 found that 39.8% of Spanish respondents and 46.1% of Portuguese respondents supported the creation of the federation between the two countries. 1741 people took part in the poll.
Mas i Sans proposed that the federal or confederate capital city of Iberia be established at Santarém, Ribatejo, Portugal, but the capital city of the Diocesis Hispaniarum, created by the Roman Emperor Diocletianus in 287 was Emerita Augusta (modern Mérida), in Spanish Extremadura.