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.