San Martin's tactical dispositions were admirably made on the momentous morning of April 5, 1818. He divided his army into two divisions and a reserve, stationing the latter on the extreme east of his line. Under cover of a heavy artillery fire the west division rushed down the slope, across the bottom, and up the hills commanding the Valparaiso road. The counter-charge of the Spanish horsemen was repulsed by the superior patriot cavalry, and the Spanish west wing was isolated from the rest of the army. Meanwhile the patriots' east division, composed of the bulk of their infantry, had charged straight across the narrow part of the bottom and reached the high ground opposite without seeing an enemy, but there was met by a terrific charge from the royalist infantry, and rolled in confusion back down the hill. Regardless of the artillery fire, the Spaniards were pursuing triumphantly over the low ground, when suddenly their eastern flank received the charge of the patriot reserve, which had advanced obliquely from its original position on the extreme east. This movement decided the battle. The Spanish infantry could not re-form to meet it, and were rolled up in helpless confusion. The flying patriot infantry rallied and returned to the attack; their cavalry, already victorious at the other end of the line, turned and charged the west flank of the Spaniards, who, simultaneously taken at both ends and in front, were cut down by hundreds. A few managed to keep their formation and fell back to the farm of Espejo, behind whose extensive buildings and garden walls they entrenched themselves, determined to sell their lives as dearly as possible. Joined by their left wing, which, unable to reach the centre where the hard fighting had taken place, had suffered little loss, they withstood the attack of the victorious patriot army. But the artillery was brought up, the walls knocked to pieces, and the position carried in the midst of the most frightful carnage. The infuriated patriots gave no quarter until General Las Heras rode among them and begged them to desist from the inhuman slaughter.
Maipo was the hardest fought battle in all the wars of South American independence. Of five thousand royalists, twelve hundred were killed, eight hundred wounded, and two thousand two hundred made prisoners. Only eight hundred escaped, flying south toward safety at Talcahuano, of whom less than a hundred held together until they reached the Spanish fortifications. Of the patriots more than a fifth were killed and wounded—the greatest sufferers being the freed negroes whom San Martin had recruited in the Argentine. Half of these brave fellows were left on the field.
Juan and Luiz Carrera, imprisoned at Mendoza, had been an embarrassment and menace to San Martin and O'Higgins. The latter hated them too much to be willing to make terms, and yet he feared that their execution would cause an insurrection by their family and party friends in Chile. A criminal prosecution had been trumped up against them and proceedings delayed on various pretexts. The news of the disaster at Cancha-Rayada was their death sentence. Dr. Monteagudo, O'Higgins's representative, acting as judge, sentenced them to death at three o'clock one afternoon and sent them to the shooting bench at five. Every Chilean who did not belong to the O'Higgins faction was profoundly shocked at this murder. Though the victims were agitators and revolutionists they belonged to one of the most respected families in Chile; with their older brother they had been the leaders in the first war against Spain; their devotion to the cause of independence was unquestioned, and they embodied the national sentiment which opposed the Argentine army's remaining on Chilean soil.
Pursuit of the Spaniards flying from the field of Maipo was hardly over when open opposition to O'Higgins and his policy broke out. A cavalry corps—the "Husares de la Muerte"—composed of Carrera partisans had volunteered after the rout at Cancha-Rayada and rendered valuable service at Maipo. O'Higgins ordered it to disband. An open cabildo met which voted the dictator's deposition, but his soldiers arrested the Carrera leader, shot him in cold blood, and the citizens had no alternative but to disperse and submit. O'Higgins undertook to crush the opposition by ferociously persecuting his republican enemies and rapaciously confiscating the property of the royalists. This so occupied him that he was unable to pay much attention to the Spaniards in the south. Osorio gathered a small force at Talcahuano, easily beat off some desultory expeditions which the patriots sent against him, and from May until September held the whole country south of the Maule. But after the slaughter at Maipo the viceroy had all he could do defending Peru and Bolivia. Late in the year Osorio withdrew with most of his troops, leaving only meagre garrisons in the fortresses of southern Chile.
San Martin had remained only a few days in Santiago, hurrying back to Buenos Aires to try to induce the Argentine government to carry out its promises of the year before and aid in the purchase of a fleet. Just before his departure an East Indiaman, carrying forty-four guns, had arrived at Valparaiso and the Chilean treasury was emptied to pay for her. When he reached Buenos Aires his friend Puerreyedon, the Argentine dictator, agreed to raise a loan of five hundred thousand dollars and send around two ships of the Argentine navy. San Martin immediately took the road for Chile, but at Mendoza a letter came forbidding him to draw on the Argentine treasury. He resigned, but the Argentine authorities, dismayed at the consequences of his withdrawal, finally gave him two hundred thousand dollars.
The winter storms make the Andean passes impracticable, and it was October before the general reached Santiago, where to his delight he found that O'Higgins had already got together a considerable squadron. The East Indiaman, bought just before Maipo, and manned by British and North American officers, had succeeded in capturing a Spanish brig. Two American privateers were shortly afterwards bought by the Chilean government, and their arrival was followed by that of an English vessel purchased by San Martin's agent in London. Others were on their way from the United States and two Argentine ships were reported to be coming around Cape Horn. A few days prior to San Martin's return to Santiago, Chile's two frigates with two smaller consorts had sailed south from Valparaiso in the hope of intercepting a fleet of transports, carrying two thousand troops and a great quantity of arms, which the Spanish government had sent around the Horn from Cadiz convoyed by a fifty-gun frigate. Stormy weather had, however, scattered the royalist fleet and more than half the transports gave up the attempt to weather the formidable promontory, though the frigate and the others succeeded. The transports evaded the Chileans and reached Callao in safety, but the frigate was caught lying at anchor in Talcahuano, and proved an important addition to the patriot navy.
The object for which San Martin had been planning and working during two years was achieved. His naval force, manned by professional sailors picked from among the best sea-fighting people of the world, was too formidable for the enemy to dare to attack. Chile was safe from invasion and Peru lay open to a descent. San Martin's first care was to wrest southern Chile from the Spaniards. To leave them in control of a fertile and populous territory where they could recruit troops, collect provisions, and menace Santiago was not safe. Toward the end of 1818 he sent his lieutenant, Balcarce, an Argentine, against them at the head of thirty-five hundred men. Such a force was irresistible; Chillan, Concepcion, and Talcahuano were abandoned and the Spanish commander shut himself up in the fortress of Valdivia.
But when San Martin came to face the question of organising and equipping an army adequate for the invasion of Peru he found the Chileans cold and indifferent. The success of their fleet had insured them against assault, and they appeared to be chiefly interested in getting rid of the Argentine army of occupation. The soldiers had not received their pay, and though O'Higgins issued a proclamation announcing an expedition to Peru, San Martin waited around for months without receiving the promised aid. Finally he presented his resignation as general-in-chief of the proposed Peruvian expedition, and withdrew the Army of the Andes from Santiago, leading a part over the Andes to Mendoza and leaving the rest on the Chilean side near the entrance to the pass. This measure quickly brought the governments of both Chile and Argentina to terms. His presence east of the Andes intimidated the rebels against the authorities at Buenos Aires, leaving the latter's hands free to aid him, while the O'Higgins party in Chile realised that it could not maintain itself without his support. He required five hundred thousand dollars for the equipment of an army six thousand strong. Chile agreed to furnish three hundred thousand and Argentina the remainder, and he returned to Santiago in the middle of 1819 to complete his arrangements. While actively engaged in preparations word came that civil war had again broken out in the Argentine. San Martin was compelled to make his choice between deferring to an indefinite future his cherished expedition against Peru, or abandoning his native country to probable disintegration. He remained in Chile and though the Argentine government, under whose commission he was acting, had ceased to exist, he did not shrink from the responsibility of disposing of the Army of the Andes. His men cheerfully agreed to follow him, but months went by with little accomplished, and it was not until late in 1820 that he was able to sail for Peru, and then with only four thousand men instead of the six he had counted on. With his departure his influence on the affairs of Chile ceased.
Lord Thomas Cochrane, a very able but very erratic British naval officer, who had gone into politics and got into trouble in his native country, arrived in November, 1818, to take command of the patriot navy. Under his dashing and restless leadership no time was lost in pushing naval operations. The year 1819 was spent in expeditions to the Peruvian and Ecuadorian coast; Callao was repeatedly bombarded, and the Spanish fleet took refuge under the guns of the fortresses, leaving the sea free to the patriots. Failing in a desperate attempt to cut out the Spanish ships from under the very guns of the Callao batteries, Cochrane sent all his vessels except his flag-ship to Valparaiso, and sailed with her for Valdivia, the last port held by the Spaniards on the Chilean mainland. The place was a very Gibraltar of natural strength, and had been well fortified. Nine forts and batteries disposed on both sides of the narrow estuary were garrisoned by over a thousand men; nevertheless Cochrane prepared to capture them by assault with his single ship. Stopping at Talcahuano he took on board two hundred and fifty Chilean soldiers, and was fortunate in finding two smaller ships. His flag-ship stranded; he transferred the marines to the other ships and went on; reaching the Valdivia bar, he landed without giving the Spaniards a moment's time to bring up reinforcements, and at the head of his soldiers and marines he attacked the outermost fort. Though defended by three hundred and sixty men its resistance was short. While Cochrane's main body advanced up a narrow path drawing the garrison's fire, a detachment found a neglected entrance in the rear through which they poured a volley on the defenders. Panic-stricken, the Spaniards fled to the next fort, but the patriots followed so close that no stand could be made. One after another all the forts on the south side of the estuary were rushed. Next day Cochrane's two smaller ships sailed into the harbour under the fire of the northern forts, and soon after the half-disabled flag-ship made her appearance. Seeing the long-boats filling with men and the cannons of the ships ready to open fire, the Spaniards fled to the city and surrendered the following day. This capture deprived the royalists of their last base of operations in Chile, and only the Chiloë Islands and a few scattered guerilla bands among the Indians of Araucania remained faithful.