In late March, Peruvian President Pedro Pablo Kuczynski resigned from office, a day before he would have been impeached. Kuczynski was the 10th Latin American president since the 1990s to leave office under the threat of impeachment.

Kuczynski’s downfall highlights some of the pitfalls of impeachment, a term that shows up a lot in the U.S. media these days. Here are some key takeaways:

1) Impeachments can help preserve democracies

Constitutions include impeachment provisions for a good reason, as presidential misconduct can threaten democracy itself. Impeachment is a legal, as well as a political, mechanism for terminating the tenures of misbehaving presidents — and a preferred mode rather than replacement via military coup or insurrection.

And impeachments serve as a deterrent, of course. We may not even be aware of all the presidential abuses averted as a result of the credible threat of impeachment.

But because presidents are judged by the legislative body, the instrument inevitably has a political component. In the United States, for instance, Alexander Hamilton warned in Federalist #65 of this risk — “the greatest danger, that the decision will be regulated more by the comparative strength of parties than by the real demonstrations of innocence or guilt.”

2) Impeachment can be an effective exit for problem presidents

Impeachment exists to solve a structural problem of presidential systems — the rigidity of fixed terms. Presidents are elected to govern for a set number of years, sometimes as many as six, but a lot can go wrong in that period. Policy errors, legal infractions, scandals, economic declines — any of these issues can make it costly for a country to endure a discredited presidency until the next election.

Latin America’s impeachment cases effectively pushed some problem presidents out of office. Fernando Collor (Brazil, 1992), Alberto Fujimori (Peru, 2000) and Otto Pérez Molina (Guatemala, 2015) were revealed as corrupt and were removed, through an impeachment in the case of Collor and by resignation under threat of impeachment in the other two cases. Collor also tried to implement an economic stabilization program without establishing the necessary support in Congress, and Fujimori was an autocrat.

3) But impeachments can undermine democracy, too

Early removal is warranted only when the president has misused the powers of office, thus threatening or undermining the standard mechanism for accountability, elections. When motivated by ideology or political opportunism, impeachment can harm democracy.

The opposition can overplay its hand, undermining confidence in the very institutions impeachment is meant to safeguard — and weakening popular support for the actors driving the process.

Ideology-driven impeachments are a problem. The opposition can accuse presidents of impropriety — while actually seeking early termination because of ideological disagreement. The impeachment of Carlos Andrés Pérez (Venezuela, 1993) was ostensibly justified on corruption grounds. Dilma Rousseff (Brazil, 2016) was impeached on a budget technicality.

In reality, legislators objected to market reforms in the Venezuela case. In Brazil, the opposition wanted to push back against Rousseff’s progressive policies. And in both cases, impeachment seekers looked for a scapegoat to distract attention from their own improprieties.

4) Impeachments can be opportunistic — this was a problem in the Peruvian case

The opposition might seek to terminate a president’s tenure simply because it can do so, rather than because of principled ideological differences. This can occur if presidents appear particularly weak and vulnerable — when approval ratings slip or when they lack a legislative shield, i.e., their legislative blocs are small or internally divided.

In these contexts, impeachment may not follow any clear evidence of malfeasance or major ideological disagreement. The chance to sack a vulnerable president is enough of a trigger.

This is what happened in Peru last month. Kuczynski narrowly defeated Keiko Fujimori in May 2016, 50.1 percent to 49.9 percent. Yet Fujimori’s party, Fuerza Popular, captured 56 percent of the seats in Peru’s unicameral Congress, and Kuczynski’s party held only 11 percent.

Fujimori and Kuczynski are not far apart ideologically, but Fuerza Popular was obstructionist from the outset. By 2017, with Kuczynski’s approval ratings around 25 percent, Fuerza Popular escalated its strategy from obstruction to removal.

With survival at stake, both sides resorted to irregular measures to corral legislative votes. Fujimori overstretched claims of corruption. A consulting firm that Kuczynski founded had received payments in 2004 and 2005 from a construction company that was now enmeshed in a massive corruption scandal involving the Brazilian construction firm Odebrecht.

There was no evidence that the payments themselves were illicit, but Kuczynski’s initial failure to acknowledge them prompted charges of “moral incompetence.”

5) Both sides in Peru went low, then lower

Kuczynski responded by going low, too. He persuaded Keiko Fujimori’s brother, Kenji Fujimori, along with a dozen Fuerza Popular legislators, to abstain from the first impeachment vote in December 2017.

Three days later, he pardoned Alberto Fujimori, Keiko and Kenji’s father, who was serving multiple sentences for corruption and human rights abuses dating from his own presidency in the 1990s. The Fujimori pardon and the blatant appearance of a deal with Kenji infuriated Peruvians.

Keiko went lower still. Moving for a second impeachment vote in March, she released secretly recorded videos showing Kenji and his allies trying to persuade a fellow legislator to support Kuczynski by promising access to government largesse. The videos killed any remaining support for Kuczynski in Congress, and the president resigned just before the impeachment vote.

In Peru, the president and his allies, increasingly convinced of the opposition’s bad faith, felt justified in violating norms of legislative behavior in self-defense. This is likely to leave Peruvians less, rather than more, confident in their institutions.

There’s a cautionary note here

Presidential democracies need impeachment procedures. They are important checks on presidential authority and can be an effective deterrent to abuses of power. But institutionally, presidential democracies must also find a way to hold impeachment seekers accountable for their actions.

What does the experience in Latin America suggest for the current discussion in the United States about electoral collusion with the Russians and prospects for impeachment? Well, it’s important to keep in mind how it can all go wrong, including the possibility that the result could be a botched process fueling the same polarization and disaffection that characterized the 2016 U.S. election.

John Carey is the Wentworth Professor at Dartmouth College. Javier Corrales is the Dwight W. Morrow 1895 Professor of Political Science at Amherst College. Mariana Llanos is a lead research fellow at the German Institute of Global and Area Studies. Leiv Marsteintredet is an associate professor of comparative politics at the University of Bergen. Aníbal Pérez-Liñán is a professor of political science at the University of Pittsburgh.