The Chilean War of Independence (Spanish: Guerra de la Independencia de Chile, 'War of Independence of Chile') was a military and political event that allowed the emancipation of Chile from the Spanish Monarchy, ending the colonial period and initiating the formation of an independent republic. It developed in the context of the Spanish American Wars of independence, a military and political process that began after the formation of self-government juntas in the Spanish-American colonies, in response to the capture of King Ferdinand VII of Spain by Napoleonic forces in 1808. The First Government Junta of Chile was formed for that purpose. But then, it began to gradually radicalize, which caused a military struggle between Patriots, who were looking for a definitive separation from the Spanish Crown; and Royalists, who sought to maintain unity with her. Traditionally, Chilean historiography covers this period between the establishment of the First Government Junta of Chile (September 18, 1810) and the resignation of Bernardo O'Higgins as Supreme Director of Chile (January 28, 1823). It is also subdivided into three stages: the Patria Vieja (1810–1814), Reconquista (1814–1817) and the Patria Nueva (1817–1823). Although the war began in 1812, the year in which the first hostile actions took place, and lasted until 1826, when the last royalist forces were defeated in Chiloé Archipelago. A declaration of independence was officially issued by Chile on February 12, 1818 and formally recognized by Spain in 1844, when full diplomatic relations were established. Background At the start of 1808, the Captaincy General of Chile—one of the smallest and poorest colonies in the Spanish Empire—was under the administration of Luis Muñoz de Guzmán, an able, respected and well-liked Royal Governor. In May 1808 the overthrow of Charles IV and Ferdinand VII, their replacement by Joseph Bonaparte and the start of the Peninsular War plunged the empire into a state of agitation. In the meantime, Chile was facing its own internal political problems. Governor Guzmán had suddenly died in February of that year and the crown had not been able to appoint a new governor before the invasion. After a brief interim regency by Juan Rodríguez Ballesteros, and according to the succession law in place at the time, the position was laid claim to and assumed by the most senior military commander, who happened to be Brigadier Francisco García Carrasco. García Carrasco took over the post of Governor of Chile in April and