The Mexican War of Independence was an armed conflict and political process resulting in Mexico's independence from Spain. It was not a single, coherent event, but local and regional struggles that occurred within the same time period, and can be considered a revolutionary civil war. Independence was not an inevitable outcome, but events in Spain itself had a direct impact on the outbreak of the armed insurgency in 1810 and its course until 1821. Napoleon Bonaparte's invasion of Spain in 1808 touched off a crisis of legitimacy of crown rule, since he had placed his brother Joseph on the Spanish throne after forcing the abdication of the Spanish monarch Charles IV. In Spain and many of its overseas possessions, the local response was to set up juntas ruling in the name of the Bourbon monarchy. Delegates in Spain and overseas territories met in Cádiz, Spain, still under Spanish control, as the Cortes of Cádiz, which drafted the Spanish Constitution of 1812. That constitution sought to create a new governing framework in the absence of the legitimate Spanish monarch.