A career military officer from the department of Cochabamba, Melgarejo slowly climbed the hierarchy of the armed forces, aided by his sycophancy, willingness to participate in rebellions, and feats of personal valor. Having participated in an 1854 military revolt against long-time dictator Manuel Isidoro Belzu, Melgarejo was tried for treason but pardoned, as he had begged for his life and blamed alcohol for his participation in the ill-fated coup. Belzú would come to rue having spared Melgarejo's life. General Melgarejo originally supported the Linares dictatorship and then fought on the side of the rebellious General José Maria de Achá, who became President in 1861. Predictably, in December 1864 he rose up against Achá and, prevailing against both the forces of Achá and former President Belzú, proclaimed himself President of Bolivia. As Belzú continued to control part of the country and army, Melgarejo sought him and, by most accounts, murdered him personally. As legend had it, at the time a pro-Belzú crowd was reunited in Bolivia's central square, opposite the Palace of Government, chanting "vivas" to the former President. At that point, Melgarejo emerged onto a balcony with Belzú's corpse and proclaimed "Belzú is dead. Who lives now?" To which the crowd is said to have replied – perhaps predictably – "Long Live Melgarejo!" Having installed himself in the Government Palace, Melgarejo proceeded to rule with more incompetence than any Bolivian leader in his time. He ruthlessly suppressed the opposition and assaulted the traditional rights of the country's indigenous population. Melgarejo worked on behalf of a new mining elite in Bolivia, during a period of resurgent silver production and investment from Chile, Peru, North America, England and European capitalists. His "sexenio" is among the most tragic in the history of Bolivia, both for his repression and his foolish give-away of lands and concessions to Chile. Hardly erudite in the arts of statecraft, he relied on his obsequious civilian aide, Mariano Donato Muñoz, especially when it came to foreign policy.
Melgarejo eventually galvanized the opposition in a concerted effort to rid the country of his tyranny. On January 15, 1871, he was toppled by the Commander of the Army, General Agustín Morales. Having fled to exile in Lima, Peru, the ex-President was assassinated in November 23 of the same year by his lover's enraged brother, Aurelio Sánchez.