The War of the Oranges (Portuguese: Guerra das Laranjas; French: Guerre des Oranges; Spanish: Guerra de las Naranjas) was a brief conflict in 1801 in which Spanish forces, instigated by the government of France, and ultimately supported by the French military, invaded Portugal. It was a precursor to the Peninsular Wars, resulting in the Treaty of Badajoz, the loss of Portuguese territory, in particular Olivenza, as well as ultimately setting the stage for the complete invasion of the Iberian Peninsula by French forces.
In 1800, First Consul Bonaparte and his ally, the Spanish prime-minister and Generalissimo Manuel de Godoy, ultimatively demanded Portugal, the last British ally on the continent, to break her alliance with Britain. Portugal refused to cede, and, in April 1801, French troops arrived in the country. They were bolstered by Spanish troops under the command of Manuel de Godoy. Godoy had, under his command, the Spanish Army of Extremadura, with five divisions
The Spanish attack to Portugal started on the early morning of the 20 May, and focused on the Portuguese border region that included the main Garrison Town and Fortifications of Elvas and the smaller fortified towns of Campo Maior, Olivença (Olivenza in Spanish) and Juromenha. The main force of the Spanish Army advanced to Elvas, while two divisions advanced to Campo Maior and another division advanced to Olivença and Juromenha. Without having their fortifications complete and defended only by a few hundred soldiers, mostly of the militias, Olivença and nearby Juromenha quickly surrendered to the Spanish forces. The Portuguese garrison of Campo Maior - under the command of Lieutenant-Colonel Dias Azevedo - resisted the assault for 17 days, forcing the Spanish to maintain two entire divisions in its siege. The main Spanish force - under the direct command of Godoy - tried to assault Elvas, but was easily repelled by the strong Portuguese garrison commanded by General Francisco de Noronha. The Spanish troops then withdrew to a safe distance from the fortress, with Godoy not daring to attack it again until the end of the war. The war entered in a stalemate, with most of the Spanish forces hold in sieges of fortresses and the rest not being able to face the blockade made by the main core of the Portuguese Army, in order to advance further inside Portugal. Despite this, Godoy picked oranges from the outside of Elvas and sent them to the Queen of Spain with the message that he would proceed to Lisbon. Thus, the conflict became known as the "War of the Oranges".
On June 6, 1801, Portugal agreed to the tenets of the Treaty of Badajoz. Portugal agreed to close its ports to English ships, to give commercial concessions to France, to cede Olivenza to Spain and part of Brazil to France, and to pay an indemnity. On September 29, 1801, Portugal agreed to both maintaining the tenets of the Treaty of Badajoz and the alterations made to it, which were all embodied within the Treaty of Madrid.
In response, from July 1801 until the signing of the Peace of Amiens in 1802, a British force of 3,500 men under Colonel William Henry Clinton occupied the Portuguese island of Madeira in the north Atlantic Ocean. Intended to forestall any French or Spanish attack on the island, the occupation took place with the tacit consent of the Portuguese.
After the Battle of Trafalgar in 1805, in which the Franco-Spanish fleet lost to Britain, the government of Portugal restored relations with its old ally. This led France to declare the Peace of Badajoz treaty cancelled, again marching on Portugal and invading it, starting the Peninsular War, that occurred from 1807 to 1810.
The French invasion forced the transfer of the Portuguese Court to Brazil, with Rio de Janeiro becoming the capital of the Portuguese Monarchy. From Rio de Janeiro, the Portuguese monarch denounced the Treaty of Badajoz as having been signed under coercion, declaring it "null and ineffective".
Later on, the Treaty of Vienna - signed by Spain in 1817 - stated clearly that the winning countries are to "endeavour with the mightiest conciliatory effort to return Olivença to Portuguese authority".
After the Napoleonic Wars, and the Congress of Vienna, neither Spain nor Portugal gave back the territories acquired both in America (Eastern Missions) and the Peninsula (Olivença); the latter remaining an issue with the Portuguese government (see Question of Olivença).