In 1812 the Spanish Constituion was promulgated in Cadiz by the "General Courts" legislative assembly. This was to be one of the most liberal constitutions of its time, where the universal suffrage, national sovereignty, constitutional monarchy, press freedom were established amongst others. The constitution was only in effect two years, since its enactment till king Ferdinand VII returned to Spain in 1814.
In 1820 Seville, a military uprising took place under command of colonel Rafael de Riego. Riego was an extremist liberal and he pronounced de reestablishment of the Cádiz constitution. There was a first election, and the winners were the more moderate liberals, but after a second election in 1922, an "exalted" government is formed fronted by Evaristo Fernández de San Miguel.
But even after the governement was established there were still many disagreements in all private and public sectors, even within factions, with many domestic riots that were encouraged by the king while he negotiated abroad for an invasion.
At Ferdinand VII's request France invaded Spain in 1823 under order of the Quadruple Alliance (Britain, France, the Netherlands and Austria) in order to support Ferdinand against the liberals and restore absolutism. The army was in charge of Duke of Angoulême, son of the soon to be Charles X of France
The French forces hardly met any resistance, except for one episode in which they were confronted by the loyal Spanish troops led by Francisco Espoz y Mina on the northern borders. Espoz y Mina found little support among the catalans and soon withdrew. The French occupied Madrid with no opposition and carried on to Andalucia.
The liberals had taken refuge in Cádiz and held Ferdinand VII as hostage. Once the French forces arrived they sieged and blockaded the city, but the resistance was fierce and they were not able to take the city. However the besieged found themselves in a rather desperate situation as no reinforcements came to their rescue.
In the end a pact was agreed betweent both parts, Ferdinand VII would promise to defend the freedom achieved by the Spanish in Spain in 1812 and in exchange the liberals would surrender the plaza. But almost as soon as he was freed Ferdinand broke his oath, not only did he abolish the 1812 Constitution, but he also made void and null all legal norms of the liberal governemnts