War of the Oranges

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. The war resulted in the Treaty of Badajoz, the loss of Portuguese territory, in particular losing Olivenza to Spain. Six years later, Napoleon would invade both Portugal and Spain in the Peninsular War.
In 1800, First Consul Bonaparte and his ally, the Spanish prime-minister and Generalissimo Manuel de Godoy, sent an ultimatum to Portugal, the last British ally on the continent, demanding that she 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 on Portugal started on the early morning of 20 May, and focused on the Portuguese border region that included the main garrison town 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, most 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 held 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, Maria Luisa, allegedly his lover, with the message that he would proceed to Lisbon. Thus, the conflict became known as the "War of the Oranges".
On 6 June 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 to pay an indemnity. On 29 September 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 lasted from 1807 to 1814.
The French invasion forced the transfer of the Portuguese Court to Brazil in 1807, 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).