The French [2nd Corps of Observation of the Gironde] were commanded by General Dupont who, in the face of growing Spanish local insurgents, decided to withdraw from the area near Cordoba. He split his command sending General Vedel ahead with 10,000 men to clear the road. The Spanish Andalusian army under General Castanos had 17,000 under General Redding defending Bailen, these troops sortied out against the head of Dupont's command. At the same time the 13,000 Spaniards under Castanos attacked the rear of the French. Although Vedel later came to the assistance of Dupont he had arrived too late. Over 18,000 men were taken prisoner and Spanish 'rebel' morale had an enornous boost.
The French disaster so shocked napoleon that he ordered 100,000 men to be withdrawn from Germany and marched to the Pyrenees. He ordered Soult, Lannes, Ney, St. Cyr and Victor to prepare to go to Spain.