Iberian federalism, Pan-Iberism or simply Iberism (Spanish and Portuguese: Iberismo, Catalan: Iberisme) are the names for the pan-nationalist ideology supporting the federation of all the territories of 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 2 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.
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.
Portugal and Spain should merge; this support is especially higher among younger Spanish nationalist citizens (18 to 24 years old) and communities near the border with Portugal. But in Spain only 3.3% would prefer Lisbon as the capital, while 80% would prefer Madrid. 43.4% think the country should be known as España/Espanha (Spain) against 39.4% preferring Iberia.
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.
The Iberian flag was created by the Catalan born Spanish diplomat and writer Sinibaldo de Mas i Sans in 1854. It is quartered with the colours of the defunct later day monarchist Portuguese (blue and white) and Spanish and Catalan flags (red and yellow), dating from 1830 and 1785 respectively. The Iberian flag is older than the second republican Spanish and Portuguese flags (1931 and 1911 respectively).
It is not a coincidence that the Iberian flag has the same colours (in a different order) as the flag of the Maritime Province of Barcelona. Barcelona was the birthplace of Mas i Sans.
According to some Iberists,[who?] the Federation or Confederation should be formed by the peninsular parts of Portugal and Spain (without the Aran Valley, which should belong to Gascony), the Balearic Islands, Gibraltar, Andorra, and the Basque and Catalan regions of France. Four languages should be official: Castillian, Galician-Portuguese, Catalan and Basque.
Mas i Sans wanted the federal or confederate capital city of Iberia to 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.