The Spanish invasion of Portugal between 5 May and 24 November 1762, was a military episode in the wider Fantastic War in which Spain and France were defeated by the Anglo-Portuguese Alliance with broad popular resistance. It involved at first the forces of Spain and Portugal until France and Great Britain intervened in the conflict on the side of their respective allies. The war was also strongly marked by guerrilla warfare in the mountainous country, which cut off supplies from Spain, and a hostile peasantry, which enforced a scorched earth policy as the invading armies approached that left the invaders starving and short of military supplies and forced them to retreat with heavy losses, mostly from starvation, disease, and desertion.

During the first invasion, 22,000 Spaniards commanded by Nicolás de Carvajal, Marquis of Sarria, entered the Province of Alto Trás-os-Montes, in the northeast of Portugal, with Porto their ultimate goal. After occupying some fortresses they were confronted with a national uprising. Taking advantage of the mountainous terrain, the guerrilla bands inflicted heavy losses on the invaders and practically cut off their communication lines with Spain, causing a shortage of essential supplies. Near starvation, the Spaniards tried to conquer Porto quickly but were defeated in the Battle of Douro and the Battle of Montalegre before they retreated to Spain. After that failure, the Spanish commander was replaced by Pedro Pablo Abarca de Bolea, Count of Aranda.

Meanwhile, 7,104 British troops landed in Lisbon, leading a massive reorganization of the Portuguese army under Wilhelm, Count of Schaumburg-Lippe, the supreme commander-in-chief of the allies.

During the second invasion of Portugal (Province of Beira), an army of 42,000 French and Spanish soldiers under Aranda took Almeida and several other strongholds, and the Anglo-Portuguese army stopped another Spanish invasion of Portugal by the province of Alentejo and won the Battle of Valencia de Alcántara (Spanish Extremadura), where a third Spanish corps was assembling for an invasion.

The allies managed to stop the invading army in the mountains east of Abrantes, where the slope of the heights facing the Franco-Spanish army was abrupt but very soft on the side of the allies, which facilitated the supply and movements of the allies but acted as a barrier for the Franco-Spaniards. The Anglo-Portuguese also prevented the invaders from crossing the river Tagus and defeated them at the Battle of Vila Velha.

The Franco-Spanish army (which had their supply lines from Spain cut off by the guerrillas) was virtually destroyed by a deadly scorched earth strategy. Peasants abandoned all nearby villages and took with them or destroyed the crops, food and all else that could be used by the invaders, including the roads and houses. The Portuguese government also encouraged desertion among the invaders by offering large sums to all deserters and defectors. The invaders had to choose between stay and starve or withdraw. The outcome was the disintegration of the Franco-Spanish army, which was compelled to retreat to Castelo Branco, closer to the frontier, when a Portuguese force under Townshend made an encircling movement towards its rearguard. According to a report sent to London by the British ambassador in Portugal, Edward Hay, the invaders suffered 30,000 losses, almost three-quarters of the original army, mainly caused by starvation, desertion and capture during the chase of the Franco-Spanish remnants by the Anglo-Portuguese army and peasantry.

Finally, the allies took the Spanish headquarters, Castelo Branco, capturing a large number of Spaniards, wounded and sick, who had been abandoned by Aranda when he fled to Spain, after a second allied encircling movement.

During the third invasion of Portugal, the Spaniards attacked Marvão and Ouguela but were defeated with casualties. The allies left their winter quarters and chased the retreating Spaniards. They took some prisoners, and a Portuguese corps entered Spain took more prisoners at La Codosera.

On 24 November, Aranda asked for a truce which was accepted and signed by Lippe on 1 December 1762.

Overview The 1762 Bourbon invasion of Portugal was actually a succession of three military campaigns in different places and times with similar results:

Background Portuguese and Spanish neutrality in the Seven Years' War During the Seven Years' War, a British fleet under Admiral Boscawen defeated a French fleet in Portuguese waters in front of Lagos, Algarve, in 1759. Three French ships of the line were captured and two were destroyed. Portugal, though an old ally of Britain, had stated her neutrality in this war and accordingly, the Portuguese prime minister Pombal demanded satisfaction from Great Britain. The British government apologized to the Portuguese king, José I, by sending a special delegation to Lisbon,"Boscawen had defeated the French fleet off the Portuguese coast. The French commander took refuge in Lagos after losing five of his ships on the coast of the Algarve. The French at once began to demand satisfaction, and Pitt sent Lord Kinnoull on a special mission to Lisbon to offer apologies." In Livermore, H. V. – A New History of Portugal , Cambridge University Press, London, 1969, p. 234. yet the captured vessels were not returned, as demanded by France (Pombal had previously informed Pitt that he did not expect it).José Hermano Saraiva (coordinator) – História de Portugal, vol. VI, Quidnovi, 2004, p. 63. The Portuguese government materially assisted the French garrisons that had taken refuge in Lagos after the battle. The French king, Louis XV, thanked José I for all the assistance given to the French sailors, although claiming for the navies. The case seemed settled, but Spain and France would use it as a pretext to invade Portugal four years later.

Portugal was having increasing difficulties in maintaining its neutrality in the Seven Years' War because of outbreaks of minor incidents between British and French: on one occasion, the British consul in Faro instructed British frigates to enter the city's harbour and prevent a French warship from unloading; and in Viana do Minho, British businessmen armed themselves and boarded a boat, recapturing a captured British merchant ship from a French corsair. Despite these incidents, the king and government of Portugal were strongly committed to keep the country out of the war.

On their part, the French were pressuring a reluctant Spain to enter the war on their side (while beginning secret negotiations with Great Britain to end it)."France's Foreign Minister, the Duc de Choiseul, had pressured Charles III of Spain to declare war against Britain, even as he was beginning secret negotiations with London to end the fighting". In York, Neil Longley – Turning the World Upside Down: The War of American Independence and the Problem of Empire, Praeger, London, 2003, p. 33. Both countries eventually signed the third Family Compact (15 August 1761), a "continental system" mainly designed to isolate Britain in Europe."Spanish invasion of Portugal, an effort to block the British in Europe, also resulted in defeat for Spain." In Altagracia Ortiz – Eighteenth Century Reforms in the Caribbean , Fairleigh Dickinson Univ Press, 1983. p. 216, footnote 16. However, British ships intercepted official correspondence from Spain to France and learned that there was a secret clause providing that Spain should declare war on Britain on 1 May 1762.Stein, Stanley and Stein, Barbara – Apogee of Empire: Spain and New Spain in the Age of Charles III, 1759–1789 , Johns Hopkins University Press, 2004, chapter The Trauma of Havana, 1762–1765.Pack, S. W. – Sea Power in the Mediterranean: A Study of the Struggle for sea power in the Mediterranean from the Seventeenth Century to the Present Day, Arthur Barker Limited, 1971, p. 68 . The British anticipated Spain, declaring war first on 2 January 1762.

The Franco-Spanish Ultimatum

Both Bourbon powers decided to force Portugal to join their Family Compact (the Portuguese king was married to a Bourbon, the Spanish king Charles's sister). Spain and France sent an ultimatum to Lisbon (1 April 1762) stating that Portugal had to:Carvalhosa, Manuel F. Barros (Viscount of Santarém) – Quadro Elementar das Relações Políticas e Diplomáticas de Portugal, Tome VI, Paris, 1850, p. XVI. Terminate the Anglo-Portuguese Alliance replacing it with a new alliance with France and Spain. Close her ports to British ships and to interrupt all commerce with Great Britain both in Europe and within the Portuguese empire. Declare war on Great Britain Accept the occupation of Portuguese ports (including Lisbon and Porto) by a Spanish army. Thus Portugal would be both "protected" and "liberated" from its British "oppressors".

Portugal was given four days to answer, after which the country would face an invasion by the forces of France and Spain. Both Bourbon powers hoped to benefit by diverting British troops from Germany to Portugal, while Spain hoped to seize Portugal and its empire."One of the main aims of the two great Bourbon powers, in the making of the Family Compact, had been to attack Portugal, in order either to compel England to send a large part of its troops to that country, or to take possession of it..."; in Philippson, Martin – The Age of Frederick the Great , vol. XV, Lea Brothers and & company, Philadelphia, 1905, p. 103.

The Portuguese situation was desperate. The great Lisbon earthquake, tsunami and fire of 1755 had completely destroyed the Portuguese capital, killing tens of thousands and damaging most of the Portuguese fortresses. Rebuilding a new Lisbon left no money to sustain an army or navy; and even the military cadres who had died in the earthquake were not replaced by 1762. From 1750 onward the Brazilian gold supply (which made Portugal by far the largest gold owner on earth during the 18th century) started its irreversible decline, and the price of Brazilian sugar also fell as British and Dutch demand reduced.Livermore, H. V. – A New History of Portugal, Cambridge University Press, London, 1966, p. 232.