On the death of Charles III in 1788, the Spanish economy began to decline. His successor, Carlos IV despite its reformist beginnings, having been overtaken by events that were happen do in France, the outbreak of the French Revolution (1789) fearing that the new liberal ideas contagiasen in Spain and had just the Old absolutist regime.
Given the lack of will to rule by King Carlos IV, the State lies in the hands of his wife, Queen Maria Luisa of Parma and his favorite Manuel Godoy, having as its main opponent to his son Prince Ferdinand.
This situation will be exploited by Napoleon, big winner of the Revolution, setting their sights on Spain, Carlos IV requires to be your ally in the conquest of Portugal. This is the excuse used by the ambitious emperor to invade the peninsula.
The French general Junot enters Spain with his troops on October 18, 1807. French troops that had a hundred thousand men, in front of which put Napoleon to General Murat, continue to occupy Spain.