The Battle of Rancagua
O'Higgins and his generals battled Spanish and royalist forces throughout Chile for another year or so before the next decisive engagement. In September of 1814, Spanish General Mariano Osorio was moving a large force of royalists into position to take Santiago and end the rebellion. The rebels decided to make a stand outside the town of Rancagua, on the way to the capital. The Spanish crossed the river and drove off a rebel force under Luís Carrera (brother of José Miguel). Another Carrera brother, Juan José, was trapped in the city. O'Higgins bravely moved his men into the city to reinforce Juan José in spite of the approaching army, which far outnumbered the patriots in the city.
Although O'Higgins and the rebels fought very bravely, the result was predictable: the massive royalist force eventually drove the rebels out of the city. The massive defeat could have been avoided had Luís Carrera's army returned, but it did not, under orders from José Miguel. The devastating loss at Rancagua meant that Santiago would have to be abandoned: there was no way to keep the Spanish army out of the Chilean capital.
O'Higgins and thousands of other Chilean patriots made the weary trek into Argentina and exile. He was joined by the Carrera brothers, who immediately began jockeying for position in the exile camp. Argentina's independence leader, José de San Martín, nevertheless supported O'Higgins, and the Carrera brothers were arrested. San Martín began working with Chilean patriots to organize the liberation of Chile.
Meanwhile, the victorious Spanish in Chile had taken to punishing the civilian population for their support of the rebellion: their harsh, cruel brutality did much to make the people of Chile long for independence. When O'Higgins returned, his people would be ready.
Return to Chile
San Martín believed that all of the lands to the south would be vulnerable as long as Peru remained a royalist stronghold. He therefore raised an army: his plan was to cross the Andes, liberate Chile and then march on Peru. O'Higgins was his choice as the man to lead Chile's liberation: no other Chilean commanded the respect that O'Higgins did (with the possible exception of the Carrera brothers, who San Martín did not trust).
On January 12, 1817, a formidable patriot army of some 5,000 soldiers set out from Mendoza to cross the mighty Andes. Like Simón Bolívar's epic 1819 crossing of the Andes, this expedition was very harsh and San Martín and O'Higgins lost some men in the crossing, although sound planning meant that most of them made it. A clever ruse had sent the Spanish scrambling to defend the wrong passes and the army arrived in Chile unopposed.
The Army of the Andes, as it was called, defeated the royalists at the Battle of Chacabuco on February 12, 1817, clearing the path to Santiago. When San Martín defeated the Spanish last-gasp attack at the Battle of Maipu on April 5, 1818, Chile was finally free. By September of 1818 most Spanish and royalist forces had retreated to try and defend Peru, last of the Spanish stronghold on the continent.
End of the Carreras
San Martín turned his attention to Peru, leaving O'Higgins in charge of Chile as a virtual dictator. At first, he had no serious opposition: Juan José and Luis Carrera had been captured attempting to infiltrate the rebel army. They were executed in Mendoza. José Miguel, O'Higgins' greatest enemy, spent the years from 1817 to 1821 in southern Argentina with a small army, raiding towns in the name of gathering funds and weapons for liberation. He was finally executed after being captured, ending the long-standing, bitter O'Higgins-Carrera feud.
O'Higgins the Dictator
O'Higgins, left in power by San Martín, proved to be an authoritarian ruler. He hand-picked a Senate, and the 1822 Constitution allowed representatives to be elected to a toothless legislative body, but for all intents and purposes he was a dictator. He believed that Chile needed a strong leader to implement change and control simmering royalist sentiment.
O'Higgins was a liberal who promoted education and equality and curtailed the privileges of the wealthy. He abolished all noble titles, even though there were few in Chile. He changed the tax code and did much to encourage commerce, including the completion of the Maipo Canal. Leading citizens who had repeatedly supported the royalist cause saw their lands taken away if they had left Chile, and they were heavily taxed if they remained. Even the Bishop of Santiago, the royalist-leaning Santiago Rodríguez Zorrilla, was exiled to Mendoza. O'Higgins further alienated the church by allowing Protestantism in the new nation and by reserving the right to meddle in church appointments.
He made many improvements to the military, establishing different branches of service, including a Navy to be led by the Scotsman Lord Thomas Cochrane. Under O'Higgins, Chile remained active in the liberation of South America, often sending reinforcements and supplies to San Martín and Simon Bolívar, then fighting in Peru.