When the Seven Years' War between France and Great Britain started in 1756, Spain and Portugal remained neutral, their differences in South America having been settled by the Treaty of Madrid of 1750.
Ricardo Wall, prime minister to King Ferdinand VI of Spain, was opposed to the pro-French party at court who wanted to enter the war on the side of France.
Portugal had been weakened by the disastrous 1755 Lisbon earthquake, leading Prime Minister Sebastião José de Carvalho e Melo, Marquis of Pombal, to direct all efforts towards the reconstruction of the country and neglected the armed forces, in which he had little interest anyhow.
They were faced by ferocious popular resistance and, from the middle of the second invasion onwards, by an Anglo-Portuguese army of nearly 15,000 men commanded by William, Count of Schaumburg-Lippe.
[32] The Portuguese abandoned their villages, inducing famine among the Spaniards, who launched two offensives towards Oporto: the first was defeated by the militia and peasants at the Battle of Douro and the second was beaten off at the mountains of Montalegre.
This failure and the arrival of Portuguese reinforcements (including regular troops) forced the now diminished Spanish army to retreat into Spain, abandoning all their conquests (except Chaves).
In the beginning of the second invasion (province of Lower Beira, July–November 1762), the Franco-Spaniards captured several poorly equipped Portuguese fortresses and towns, including Almeida.
The outcome was the destruction of the Franco-Spanish army, whose remnants – leaving their wounded and sick behind – were chased to Spain by the Anglo-Portuguese army and peasants, after two encirclement movements undertaken by a Portuguese force under General George Townshend, 1st Marquess Townshend toward the enemy's rear: the first move forced the Bourbons to withdraw from the hills east of Abrantes to Castelo Branco, while the second made them flee to Spain.
Aranda [immobilized by the excellent Anglo-Portuguese defensive positions in the mountains near Abrantes] was forced to choose between withdrawing or starve to death in Beira.
Then, taking advantage of the disorder caused by the withdrawal, The Count of Lippe outlined a plan that would imprison Aranda and all his army in Castelo Branco [The Spanish headquarters].
Bourbon casualties mounted because the Portuguese peasantry waged a relentless war of revenge against deserters and retreating soldiers who they captured and massacred in large numbers (p.
"[42]During the third Spanish offensive (November 1762), the Spaniards attacked by surprise two Portuguese towns (Ouguela and Marvão) – but were defeated -[43] and had to retreat again before the reinforced and advancing Anglo-Portuguese army, which took some prisoners.
Additional Spanish prisoners were taken when a Portuguese force led by British Colonel Wrey entered Spain and attacked the region of Codicera on 19 November.
The Portuguese conquered most of the valley of Rio Negro, expelling the Spaniards from S. Gabriel and S. josé de Maribatanas (1763) and building two fortresses there with the Spanish cannons.