A power struggle coupled with the most far-reaching corruption probe Brazil has ever seen means the countrys democracy is in for a stormy 2017.

One side of the increasingly complex crisis in Latin America's biggest economy pits the corruption-riddled political class in Brasilia against aggressive prosecutors running the so-called Carwash probe of embezzlement at state oil company Petrobras.

The mostly under-the-carpet struggle has started to erupt into the open. This month, one Supreme Court justice tried to force the scandal-tainted Senate president, Renan Calheiros, to step down, only to be rebuffed by Calheiros and eventually overruled by the rest of the court.

Congress, meanwhile, is trying to push through laws that would target prosecutors and judges for "abuse of authority" and even to grant themselves immunity for past crimes of corruption.

Ivar Hartmann, a law professor at the Getulio Vargas Foundation in Rio de Janeiro, calls this "pure revenge."

'Lynch mob' atmosphere

Underlying the crisis is the Carwash probe, which has uncovered extensive, high-level involvement in a scheme that saw politicians take bribes to help contractors win inflated contracts from Petrobras.

Big names have already fallen, including the once-powerful speaker of the lower house of Congress, Eduardo Cunha, who is in jail awaiting trial for allegedly taking millions of dollars in bribes. And there is no end in sight.

"Carwash has a life of its own. No one can control it," said Marcos Cepik, a foreign affairs specialist at the University of Rio Grande do Sul.

Plea bargains by 77 executives at Odebrecht, the huge construction company at the heart of the Petrobras embezzlement scheme, have been completed and leaks from the testimony indicate that scores more politicians will be accused of corruption.

President Michel Temer, who took over this year after the impeachment of Dilma Rousseff, has reportedly been named as having received suspicious donations. So have several of his closest allies and advisers.

But powerful voices are arrayed against the Carwash prosecutors.

Romero Juca, a Temer confidant who represents the government in Congress and is also a suspect in the Carwash probe, lashed out at media leaks of the sealed testimony in the plea bargains.

"These leaks will weaken the country's stability. In this atmosphere of unrest, of the lynch mob, of a French Revolution, we'll never attract investors," he said in the newspaper Estado de Sao Paulo.

On the other side of the political aisle, former president Luiz Inacio Lula da Silva, who likely will face trial in 2017 as part of the Carwash prosecution, claims he is the victim of persecution.

Cepik, the foreign affairs specialist, says that the turmoil could lead to a new Brazil "with low tolerance for corruption."

But if opponents of Carwash succeed in closing down the investigation, it will be "the end of Brazil."

A sharper memory

Meanwhile, Brazil's leaders have a long to-do list if the country is to escape a profound economic recession.

Temer is supposed to rule to the end of 2018 and has a goal of reversing more than a decade of leftist policies, using austerity measures to restore fiscal responsibility.

Congress has approved the first part of the program, a 20-year spending cap, but has yet to vote on pension and other reforms. Recent polls show Temer has rock-bottom popularity.

So far, though, he has been able to ride out attempts to impeach him, and his center-right coalition has maintained a strong grip on Congress. Although he is unloved, there have been only modest-sized street demonstrations against his policies.

"There is popular sentiment in favor of cleaning up politics, but not so much against the government," said Murilo Aragao, from Arco Advice risk consultants.

But that could change if the Odebrecht testimony is "really toxic."

The leader of the movement Vem Pra Rua (Take to the Streets), Rogerio Chequer, says that there will be a reckoning when elections are held in 2018.

"We no longer have a short memory. In 2018 we will remember everything the politicians did," he said this week.