Peru remained a Spanish colony through the next few centuries. Even as wars of independence rocked the rest of South America, Peru was a royalist stronghold. It was the last country to gain its independence, in 1821.
The fledgling country rocked between military rule and political infighting. Peru engaged in war with Chile in the War of the Pacific from 1879-83, in which they were defeated. Military coups, political turmoil, and radical reforms characterized the country for the next several decades. A period of stability settled under the presidency of Alberto Fujimori, but he was forced to resign in 2000 under accusations of human rights violations and corruption.