At this juncture the Bolivian congress voted not to ratify a treaty negotiated with Chile four years before, and passed a law imposing heavy taxes on the nitrate business. The Chilean companies protested and resisted; their government backed them up, and sent a fleet to protect their interests. Enraged at the seizure of her ports, Bolivia declared war in March, 1879. Peru could not be expected to remain quiet. Not only was she bound by the solemn agreement of the treaty of alliance, but she had an imperative selfish interest in preventing the disputed nitrate territory from falling into Chile's hands. She began to gather an army on the southern frontier, but she was illy prepared for war and Chile knew it. Her offers of arbitration were promptly rejected; the Chilean government had determined to strike both allies at the same time, and presented an ultimatum, demanding that Peru abrogate the secret treaty, cease warlike preparations, and remain neutral in the war with Bolivia. Failing immediate and categorical compliance war was declared in April.
What had proven true in the time of Pizarro, San Martin, and Santa Cruz, was still true—the successful invasion or defence of Peru depended on the control of the Pacific. Whichever power should obtain a naval preponderance would surely get the nitrate territory—a rainless, cropless region where an army must be sustained by supplies brought by sea—and then could attack the other at its capital. Chile had two new iron-clads, the Cochrane and the Blanco, besides two good cruisers and several gunboats. The two Peruvian iron-clads, the Huascar and the Independencia, were older, though their speed was superior. The Chileans opened the war on the ocean by blockading the Peruvian ports in the extreme south, but Miguel Grau, the able seaman and intrepid fighter who commanded the Peruvian fleet, at once attacked the Chilean cruisers which were lying off Iquique. The Huascar rammed and sank the Esmeralda, but while his other iron-clad was pursuing the Covadonga, she ran upon the rocks and was lost. This was in reality a deathblow to Peru, but the gallant Grau devotedly determined to see what his single ship, rapidly manœuvred, could do to make unsafe the embarkation of a Chilean army. For four months he terrorised the coast from Antofagasta to Valparaiso. Chile could not take a step until she had disposed of Grau and his dreaded Huascar. The blockade of Iquique was abandoned as useless; the iron-clads ordered back to Valparaiso to be cleaned and repaired so that they might match the Huascar in speed; new officers were put in command; and on October the first the Chilean fleet set sail from Valparaiso on a systematic chase for the Peruvian iron-clad. On reaching Antofagasta it was divided into two squadrons, the Cochrane leading one and the Blanco the other, and they immediately began patrolling the coast.
The Huascar, accompanied by a consort, the Union, was cruising in the neighbourhood, and at daylight on the 8th of October the first Chilean division sighted her. Grau fled, and was gradually drawing away from his pursuers when, to his horror, three columns of smoke appeared on the horizon directly forward. He was caught between the two Chilean squadrons. The Union had speed enough to slip by the enemy, but the Huascar was too slow. Grau's only chance was to close with the Cochrane before the Blanco could come up astern, and he went straight for the former. At half past nine the Huascar fired the first shot, the distance being about three thousand yards. It fell short and only the fourth shot took effect. The Cochrane then replied, and though the practice on both sides was wild, the two ships soon came so close that the machine guns were brought into effective play. A shot disabled the Huascar's turret, and in desperation Grau tried repeatedly to ram, but was foiled by the quick turns which the Cochrane's twin screws enabled her to make. Just half an hour after the action began a shell struck his conning-tower, blowing the heroic Peruvian into atoms. A few minutes later the Blanco came up and added her missiles to the storm of shots which the Cochrane and the smaller consorts were pouring upon the doomed Huascar. Nevertheless no one thought of striking. Hardly had Grau been blown to pieces than the executive officer had his head taken clean off by a shell from the Blanco, and the officer next in seniority was severely wounded. A few moments later the lieutenant who succeeded to the command was killed, and his successor, in turn, was wounded before the end of the action. When the ship finally struck, an hour and a half after the first shot was fired, one of the juniors was in command, and sixty-four of the complement of one hundred and ninety-three officers and men lay killed or wounded on the deck.
The Chileans were now in absolute control of the sea, and could land an army when and where they pleased. The Bolivian sea-coast, inhabited almost exclusively by Chilean miners, and inaccessible overland from Bolivia proper, had fallen into Chile's hands at the opening of the war, but Grau's success in immobilising the Chilean navy had been taken advantage of by the Peruvians to ship nine thousand troops to their own nitrate province, where they could conveniently attack the Chileans who occupied the Bolivian territory to their south, or defend their own most valuable piece of property. But although this army was in Peruvian territory the naval victory of the Chileans isolated it almost completely. A hundred miles of rough, rainless desert, intercepted by deep ravines transverse to the coast, separated it from Tacna, where fertile valleys begin and communication with the rest of Peru becomes possible.
By the end of October the Chilean army embarked at Antofagasta ten thousand strong and well provided with cavalry and the most modern artillery. Of Iquique and Pisagua, the two principal ports of the Peruvian nitrate country, the latter, which lies forty miles north of the former, was chosen as the less likely to be defended in force. Only a thousand men were found, who, in spite of a gallant resistance from their two small batteries and their rifle pits, were unable to prevent the landing of the Chileans protected by a tremendous fire from the fleet. Driven from the town the Peruvians could not even hold the top of the precipitous bluff until the arrival of reinforcements from Iquique. The Chileans relentlessly pushed their advantage and soon were in possession of the railroad for fifty miles into the interior and had six thousand men entrenched on a hill called San Francisco. Abundantly supplied with provisions and water they could afford to wait, while the allies, cut off from communications, must either attack at once or abandon the province. The Peruvian general chose the former alternative, but his troops arrived in front of San Francisco exhausted and thirsty after a twenty-miles' march across the dry desert. Only a small part of the army took part in the assault, and it was easily repulsed. Disheartened the allies fell back to the foot of the giant range which inexorably barred their way to the east, and after a few days of suffering from hunger and thirst, took their way north among the barren foothills. The enemy sent a detachment to harass their march, but they turned on their pursuers and defeated them, and reached Tacna province hungry, ragged, half-armed, and generally demoralised.
Not only was the great nitrate province, the treasury of Peru, irretrievably lost, but every point on the coast, including Lima itself, laid open to attack. President Prado left the army at Tacna, went to Lima, and thence sailed for Europe, announcing that he was going to buy iron-clads. Hardly was he on board ship when a revolution broke out in the capital, and the restless Pierola, who had headed the latest attempts at insurrection, declared himself supreme chief. The Bolivians also deposed their unsuccessful president. Peru's revolutionary government, rushed into power on a wave of wounded national pride, embodied the more than Spanish haughtiness of the Creole aristocracy, and refused all concessions. The allies still had a large army at Tacna, not too demoralised to make a creditable resistance, although it was cut off from easy communication with the rest of Peru and Bolivia, and stood badly in need of arms, clothing, and ammunition. The Chilean ships blockaded Arica, the Tacna port, but the fast Union again showed her heels to the enemy's whole fleet, ran the blockade, and landed stores which put the allied army on a fighting footing.
Late in February, 1880, the Chileans disembarked a fine army of fourteen thousand men at a seaport sixty miles north of the allies' main position, and lost no time in occupying the interior as far as Moquegua at the foot of the Andes. Their first object was to cut the allied armies off from any communication with their respective countries. A small Peruvian force made an attempt to hold Torata, a point strategically important because it commanded the entrance into the Andes from Bolivia and Peru, but was unsuccessful. The allied armies were now bottled up in a little valley where provisions would surely shortly fail. The Chileans advanced south across the desert upon Tacna, and the allies took a strong defensive position on a ridge, flanked by steep ravines, with a sloping glacis in front. Vastly superior in artillery, though only slightly outnumbering the allies, the Chileans thought themselves justified in assaulting the position. They opened the battle by a cannonade in which their magnificent Krupp guns did terrific execution, and under cover of the fire the infantry advanced in four columns of twenty-four hundred men each. Approaching the trenches they were met by a storm of rifle bullets through which they charged bayonet in hand.
Meanwhile the allies on the crest of the sand-hills suffered terribly from the plunging artillery fire. The Bolivians, holding the weakest part of the line, bore the brunt of the attack. Once the Chileans wavered, but a supporting cavalry charge quickly drove back the advancing enemy, and after two hours of desperate fighting the sturdy Bolivian Indians gave way, their position was carried, and the allied army fled all along the line. Though the Chileans had lost over two thousand, the losses of the allies were greater. No way of retreat lay open; they scattered in confusion; and their army virtually ceased to exist. A couple of thousand Peruvians held out in Arica for a month, deliberately devoting themselves to certain death, but the place was carried by an assault in which quarter was neither given nor asked.
Peru now lay helpless at the mercy of the Chilean armies and fleet. The ports were blockaded and bombarded, while expeditions ravaged the fertile coast valleys. Nevertheless the Peruvians would not yield. The United States offered her mediation, and plenipotentiaries met to see if terms of peace could be arranged. Chile demanded the formal cession of the nitrate territory and an indemnity. The Peruvians refused such hard terms, hoping against hope for foreign intervention. This passive obstinacy enraged the Chilean government, and after a delay of several months it was determined to capture the capital and dictate terms at Lima. Late in December, 1880, a splendidly equipped army of twenty-six thousand men landed a short distance south of Lima and marched on the city. Only a few fragments of the Peruvian regular army had survived the defeats in the south, but the population rallied en masse to resist the invaders. At Chorrillos, a few miles south of Lima, the militia waited behind a hastily constructed line of defence. The assault of the Chilean regulars was irresistible; four thousand Peruvians perished, and as many more were taken prisoners. The survivors fell back on a second line of defence, only six miles from Lima, and were there defeated in a second battle in which two thousand were killed and wounded. The Chilean losses in the two fights reached five thousand. On the following day the mayor of Lima formally surrendered the city, and on the 17th of January the Chilean army took possession. The helpless citizens were required to make up a contribution of a million dollars a month; the customs duties were confiscated, and the Chileans violated all the rules of civilised warfare by wantonly destroying the great and valuable public library—the best in South America.
Pierola escaped to Guamanga, but succeeded in rallying no forces. He gave it up and went to Europe. It became necessary to organise a government which could treat for peace. The citizens of Lima, with the consent of Chile, made Garcia Calderon provisional president, but when the discussion of terms began the Chileans repeated their demand for the unconditional cession of the nitrate territory, and Calderon did not dare assent. The enemy sent him prisoner to Santiago, while Iglesias in the northern departments, Caceres in the centre, and Carrillo in the south each kept up an independent resistance with a few militia. The Chileans made no serious attempt to conquer the interior, contenting themselves with pocketing the Peruvian customs revenues. This situation lasted two years and a half, until Iglesias came to the conclusion that peace could only be obtained by complete submission. Caceres was, however, resolved upon further resistance and quarrelling with Iglesias, advanced into the latter's territory. He was intercepted by a Chilean expedition and his forces destroyed. This left Iglesias a clear field; he declared himself president and entered into negotiations with the Chileans, arranging a treaty of peace which was signed on the 20th of October, 1883. Five days later the Peruvian flag was once more hoisted in the capital. Sporadic risings against Iglesias were easily suppressed by Chilean bayonets; four thousand men remained to see that the treaty was ratified, and a convention finally ratified it in March. Its provisions differed little from the demands made by Chile three years before. The money indemnity was waived and half the guano proceeds were left to Peru's creditors. On the other hand, the provinces of Tacna and Arica were to be held by Chile for ten years, and at the end of that time a popular vote would decide who should retain them, the losing country receiving ten million dollars from the other. Better far for the interests of permanent peace had the fate of the provinces been definitely determined. Chile and Peru have never been able to agree upon the terms under which the plebiscite should be conducted; the former still retains the provinces and the latter still agitates for their recovery.