After having soundly defeated Marshal Auguste Marmont's French army at the Battle of Salamanca in July 1812, Wellington exploited his great victory by advancing on Madrid.
The magnitude of Wellington's triumph also compelled Marshal Nicolas Soult to evacuate Andalucia in the south and withdraw to Valencia.
Wellington's victory over Marshal Marmont at the Battle of Salamanca on 22 July 1812 gravely weakened the French position in Spain.
He wrote to the king, "armies usually suffer in morale after a setback, [but] it is hard to understand the extent of discouragement existing in this one.
Leaving 18,000 troops with Lieutenant General Henry Clinton to watch Clausel, the British army commander turned toward Madrid with 36,000 men.
[7] The following day, the Retiro forts were put under siege and 24 hours later they surrendered to Wellington, yielding 2,046 prisoners, large stocks of clothing and equipment, including 20,000 muskets and 180 brass cannon [8] as well as the eagles of the 13th Dragoon and the 51st Line Infantry Regiments.
[9] Harassed by guerillas and tortured by thirst, Joseph's soldiers retreated all the way to the east coast city of Valencia, which they reached on 31 August.
He counted on the autumn rains keeping the Tagus River high and preventing Joseph and Soult from threatening his southern flank.
[10] To Wellington's amazement, Clausel quickly rallied his beaten army and launched a raid in the north.
In the face of this advance, Clinton fell back to Arévalo with 7,000 soldiers while José María Santocildes's Spanish corps abandoned Valladolid.
While the Spanish attackers concluded the siege of Astorga before he could reach it, Foy rescued the garrisons of Toro and Zamora and reunited with Clausel at Valladolid on 4 September during the French autumn counterattack.
The British army commander set out after Clausel, but that general easily shook off his pursuers and dashed out of reach, leaving a garrison of 2,000 men in Burgos.
[11] Wellington left Lieutenant General Rowland Hill to defend Madrid with 31,000 Anglo-Portuguese and 12,000 Spanish.
[2] Admiral Sir Home Popham of the Royal Navy offered to land more heavy guns at Santander, but Wellington declined to use this resource.
[14] After costly assaults at the sieges of Ciudad Rodrigo and Badajoz, he was loath to mount a massive infantry attack.
[18][8] Wellington ordered an assault on the San Miguel hornwork, which guarded the fort's northeast approaches for the night of 19 September.
Launched without the benefit of artillery support, there were three simultaneous assaults, the 1st Battalion of the 42nd Foot was spotted by the French in the moonlight and over 200 men were mowed down.
When this was detonated in the early hours of the 29 September, part of the wall collapsed, the advanced party of British dashed forward but were not supported and were soon driven back from the defences.
[14] When the new mine was finally ready on 4 October, it was fired, blowing a 100-foot gap in the northwest wall and killing most of the defenders in that area.
The British guns on the hornwork ran so low on ammunition that French cannonballs were retrieved and reused.
With a French army threatening his position and with the problems arising from the shortage of artillery and ammunition, Wellington made preparations to retreat on 21 October.
[14] Soult raised the siege of Cadiz on 25 August 1812 and abandoned a huge wagon train of booty in Seville on the 28th.
In the south Hill occupied Toledo with 20,000 soldiers while Major General Charles Alten held Madrid with 18,000.
High hopes had been placed on 8,000 Anglo-Sicilians[16] under Lieutenant General Thomas Maitland at Alicante on the east coast.
Wellington was 150 miles (241 km) north of Madrid at Burgos, dangerously separated from Hill's army.
The Allied retreat continued until Wellington and Hill joined forces on 8 November near Alba de Tormes.
[31] Logistical arrangements in Wellington's army collapsed and the Allied soldiers marched in cold pouring rain for four days with very little food.
Before reaching the friendly fortress of Ciudad Rodrigo, the Allied armies lost 5,000 men missing, mostly soldiers who had died from hunger or exposure in the chaotic retreat.