Demonstrators opposed to President Dilma Rousseff watch in Sao Paulo as the lower house of Congress votes to impeach her on April 17, 2016. (Igo Estrela/Getty Images)

When street protests forced Guatemala’s president to step down last fall amid a corruption scandal, it seemed a rare break in a long and lucrative tradition of impunity in Latin America.

Now that event looks like a first salvo in a sweeping new push for cleaner government. Bribery and influence-peddling scandals are roiling countries from Mexico to Chile. Armed with new legal tools and the supercharged activism of social media, an emerging, anxious middle class is increasingly well-informed, unintimidated and unwilling to accept the notion of public office as a path to self-enrichment.

“We’ve always had corruption, but there has been a fundamental shift in its exposure and the ability to take it on,” said Shannon O’Neil, an expert on the region at the Council on Foreign Relations.

[Kickbacks, dirty deals and more: The corruption scandals plaguing Latin America]

In Brazil, a sprawling graft investigation at state oil company Petrobras has walloped the governing party and brought President Dilma Rousseff to the brink of impeachment. Investigators in Argentina are circling former leader Cristina Fernández de Kirchner, whose wealth multiplied while she was in office. The headlines in Peru, Ecuador and other nations are dominated by stories of kickbacks, bribes or murky offshore accounts.

The current drive does not have the same fervor everywhere, and it would be naive to expect such an old scourge to go away overnight. The problem runs even deeper in areas controlled by drug traffickers.

Much of Latin American corruption has its origins in the top-heavy centralization and venality of Spanish colonial rule. The military dictatorships of the Cold War era were not much better, and in too many cases, the arrival of democracy only magnified the opportunities to steal. The parasitic culture of graft functions as a kind of growth-sapping tax, development experts say, and undermines trust in democratic institutions.

The difference today is that across much of Latin America, new legal mechanisms are rooting out crimes that might have gone undetected in the past. In Brazil, judicial reforms enacted under Rousseff’s own Workers’ Party in 2013 expanded the plea-bargaining system that is rolling up some of its members today — along with scores of other Brazilian politicians.

Investigators have used it like a crowbar to crack open old walls of silence, persuading party cronies to turn against one other.

[How Brazil, the darling of the developing world, came undone]

A U.N.-sponsored independent judicial body in Guatemala, known by the initials CICIG, helped give prosecutors, judges and ordinary citizens the confidence to take on powerful figures such as former president Otto Pérez Molina. In the past, the country’s authoritarian governments easily controlled the courts and silenced activists.

But democracy has matured in many parts of Latin America, analysts say. The human rights groups that courageously stood up to military dictatorships a generation ago are today joined by civil society organizations pushing for more transparency and accountability. Press freedom has improved in many countries. Social media has given ordinary citizens a powerful tool to amplify their anger and channel it into the streets.

“Our generation is saying that if we want to overcome these problems, it’s now or never,” said Álvaro Montenegro, 28, a Guatemalan law student who was one of the principal organizers last year of the movement to oust Pérez Molina.

Montenegro’s group used Facebook to publish essays and testimonials and share information on alleged crimes. Twitter became the group’s most powerful weapon for marshaling street protests, allowing direct communication with supporters and the news media, and forcing politicians to engage directly, he said.

New anti-corruption laws are on the books or are working their way through legislatures in Mexico, Colombia and Chile, a response to citizen demands for cleaner government.

They reflect the growing political clout of a new and nervous Latin American middle class that is determined not to slide backward. During the early 2000s, a commodity boom fueled largely by Chinese demand lifted millions out of poverty. Now prices for oil, minerals and agricultural products are in a slump and the helium has gone out of the region’s economies.

With less money for social-welfare programs, incumbent leaders have seen their popularity deflate and their finances — and public budgets — come under greater scrutiny.

The export-driven bonanza produced opportunities for influence peddling and graft on a new scale. Many of the region’s biggest companies in industries such as mining and petroleum are state-owned firms that produced vast fortunes along with new ways to pilfer them.

As much as $12 billion was leeched from Petrobras, once the motor of Brazil’s growth, according to the “Car Wash” judicial investigation, which has exposed a sordid culture of skimming and theft by company executives and politicians.

Rousseff herself is not accused of stealing, but she was chairwoman of the Petrobras board of directors when seemingly everyone around her was feeding from the trough.

[How Brazil’s impeachment process works]

Because the good times were also a period of big government budgets, analysts say, they boosted expectations about the role of the state in redistributing wealth and providing services.

“In the context of economic deceleration and budget tightening, unabated or even growing corruption in much of the region becomes particularly unseemly,” said Michael Shifter, president of Inter-American Dialogue, a D.C. think tank specializing in Latin America. “Public revulsion towards such tawdry behavior is spreading.”

Even leaders with squeaky-clean reputations, such as Chilean President Michelle Bachelet, have been tarred. With her daughter-in-law facing charges of tax evasion and bribery, the once-popular Bachelet’s public approval has dropped to 25 percent.

Like Brazil’s Rousseff, she is among the leftist leaders who rose to power in the past decade in part on the idea that they stood apart from the business world and would not succumb to its temptations.

In November’s presidential election, many Argentines professed the opposite view, supporting wealthy businessman Mauricio Macri on the idea that he would not need to steal if he was already rich.

But Macri’s honest-broker reputation took a hit this month when he turned up in the Panama Papers as the former director of an undeclared offshore company. He denies any wrongdoing and says he never made any money from the firm. Fernández, too, insists she is innocent but was called to testify this month in a fraud case, and a prosecutor has sought to include her in a money-laundering investigation.

Unlike in the United States, where influence peddling has a legal outlet in the lobbying industry and a campaign funding system, in Latin America, the idea of big money in politics remains largely taboo. So it thrives in the shadows.

Latin American political campaigns are becoming more costly and competitive than ever. There is virtually no culture of small-voter donations, so candidates often turn to business interests to build their war chests. Some also pad their personal fortunes.

“It’s a huge generalization, but in the United States, politicians have different incentives,” O’Neil said. “You can’t be seen as corrupt when you’re in office, but if you’re an upstanding public official you can get a swanky private-sector job once you leave office.”

“Your earning power goes up,” she said. “Whereas the earning power of Latin American politicians is never higher than when they are in office.”

Read more:

How Brazil’s governing Workers’ Party lost the workers

Five reasons that the world needs Brazil to pull through its political crisis

Brazil’s new hero is a nerdy judge who is tough on official corruption