With Portugal secured, Wellesley advanced into Spain to unite with Cuesta's forces. Victor's I Corps retreated before them from Talavera. Cuesta's pursuing forces fell back after Victor's reinforced army, now commanded by Marshal Jean-Baptiste Jourdan, drove upon them. Two British divisions advanced to help the Spanish. On 27 July at the Battle of Talavera, the French advanced in three columns and were repulsed several times, but at a heavy cost to the Anglo-Allied force, which lost 7,500 men for French losses of 7,400. Wellesley withdrew from Talavera on 4 August to avoid being cut off by Soult's converging army, which defeated a Spanish blocking force in an assault crossing at the River Tagus near Puente del Arzobispo. Lack of supplies and the threat of French reinforcement in the spring led Wellington to retreat into Portugal. A Spanish attempt to capture Madrid after Talavera failed at Almonacid, where Sébastiani's IV Corps inflicted 5,500 casualties on the Spanish, forcing them to retreat at the cost of 2,400 French losses.