In July 1812, after the Battle of Salamanca, the French had evacuated Madrid, which Wellington's army entered on 12 August 1812. Deploying three divisions to guard its southern approaches, Wellington marched north with the rest of his army to lay siege to the fortress of Burgos, 140 miles (230 km) away, but he had underestimated the enemy's strength and on 21 October he had to abandon the Siege of Burgos and retreat. By 31 October he had abandoned Madrid too, and retreated first to Salamanca then to Ciudad Rodrigo, near the Portuguese frontier, to avoid encirclement by French armies from the north-east and south-east.
Wellington spent the winter reorganising and strengthening his forces. By contrast, Napoleon withdrew many soldiers to rebuild his main army after his disastrous invasion of Russia. By 20 May 1813 Wellington marched 121,000 troops (53,749 British, 39,608 Spanish and 27,569 Portuguese) from northern Portugal across the mountains of northern Spain and the Esla River to outflank Marshal Jourdan's army of 68,000, strung out between the Douro and the Tagus. The French retreated to Burgos, with Wellington's forces marching hard to cut them off from the road to France. Wellington himself commanded the small central force in a strategic feint, while Sir Thomas Graham conducted the bulk of the army around the French right flank over landscape considered impassable.
Wellington launched his attack with 57,000 British, 16,000 Portuguese and 8,000 Spanish at Vitoria on 21 June, from four directions.