Eduardo Cunha speaks during a news conference at the National Congress in Brasília on July 17. (Antonio Cruz/Agencia Brasil/AFP/Getty Images)

RIO DE JANEIRO -- There are times in Brazil’s young democracy -- its constitution dates from 1988 -- when the country seems to be making things up as it goes along.

This is one of them.

What began in 2014 as a police investigation called “Operation Car Wash” has spiraled into a horrendously dense drama, in which some of Brazil’s top politicians and largest companies have been forced into leading roles under harsh lights.

Since last year, an increasing number of accusations and counter-accusations have been whirling around state-controlled oil giant Petrobras and some of its top former executives -- involving oil refineries, rig contracts, political parties, shadowy agents and middlemen, construction companies and cartels. Not to mention billions of dollars in payoffs and bribes.

As the scandal climbs higher up the political hierarchy, the more complex it feels and the more explosive reactions it causes.

[‘Operation Car Wash’ in Brazil causes normally staid business meeting to go off script]

In video testimony released last week, a key witness who brokered lucrative Petrobras contracts for suppliers and has agreed to a state’s evidence deal said the combative speaker of the House demanded and received $5 million in overdue bribes. Eduardo Cunha, the witness testified, got another $5 million for his Brazilian Democratic Movement Party, known by its Portuguese acronym, PMDB.

Cunha denied the allegations, saying the investigation and its timing were manipulated by the government. On Friday, he quit the governing coalition, while keeping his speaker’s chair.

His party, which called his decision to join the opposition a personal one, didn't leave the government. It appears to be clinging to an alliance with President Dilma Rousseff's Workers’ Party that it no longer believes in, given its plan to field a candidate in the 2018 presidential election.

A televised address Cunha made that day, with no mention of the accusations, was greeted in some cities with saucepan bashing and jeers.

Renan Calheiros of PMDB, the Senate president, praised Cunha in his own on-air remarks while attacking the government and arguing that the failing economy had contaminated politics. “We are in the dark, watching an endless horror film," he said. "And we need a light to indicate that the horror will have an end.”

Conservative commentators have also defended Cunha, including some vociferous government critics.

His decision to quit Rousseff's coalition added to the questions currently reverberating through Brazilian politics.

How will Congress work when its speaker opposes the government but his party remains allied? Will Calheiros, who is also being investigated, be dragged in? And what will he do then? Can Rousseff, who so far is untouched, but who was both chairwoman of the Petrobras board of directors and a Minister of Mines and Energy, survive?

[Does Brazil's new speaker of the lower house want the government to fall?]

The Cunha news broke around the same time as it emerged that prosecutors had formalized a separate investigation into the populist former Workers’ Party President, Luiz Inácio Lula da Silva, known as Lula, which involves a company cited in the Petrobras inquiry.

Investigators are looking into accusations of influence peddling by Lula on behalf of Brazilian conglomerate Odebrecht for contracts in Africa and the Americas. Lula and Odebrecht have denied the allegations.

On Wednesday, the Web site of newspaper Estado de S.Paulo published diplomatic cables released by WikiLeaks that indicated American diplomats suspected irregularities in Odebrecht projects in Venezuela, Panama, Angola and Ecuador during Lula’s time in office. One cable said a Lula visit helped conclude an Odebrecht deal in Angola.

The company's CEO and four other executives are jailed in connection with the Petrobras probe and federal police have offered evidence against them. Here, too, they deny the allegations and have not yet been formally charged.

Each new revelation increases the temperature in Brazilian political circles. With the economy sinking further and Rousseff, Lula's protégée, down to a single-digit approval rating, their impact could swell anti-government demonstrations planned across the country on Aug. 16.

It's a situation that conjures up haunting echoes of Brazil's past. In 1992, following a major corruption scandal and mass demonstrations, President Fernando Collor was impeached. In 2005-06, a wide-reaching, vote-buying scandal threatened the Lula government.

[Brazil’s embattled president responds to her critics]

But this is uncharted territory. The three pillars of Brazil's democracy -- the executive, legislature and judiciary -- are each testing their strength and battling for position. So far, only the judiciary is coming out it well.

While lawmakers look worried and Rousseff weakened, Sergio Moro, the swashbuckling judge central to the Petrobras inquiry who has jailed powerful executives and politicians, has delighted many Brazilians unused to seeing the mighty humbled.

Where this goes, nobody knows.

One thing is for sure: Rousseff’s "fiscal adjustment," seen as crucial to the recovery of Brazil’s economy, will be even more difficult to get through Congress, said Ricardo Ismael, a political scientist at Rio’s Pontifical Catholic University. Congress has reduced some of the planned cuts and the government has just slashed a primary surplus target it was unlikely to hit.

What is also certain: this is progress, of a kind.

At other times in Brazil’s turbulent history, a political crisis of this intensity might have ended in a coup, said Paulo Sotero, director of the Brazil Institute at the Woodrow Wilson International Center in Washington D.C. In 1964, the military exploited a political crisis and fears of a communist takeover, and with U.S. support installed a dictatorship that lasted two decades.

Brazil’s democracy is wobbling, but the tremor will make it stronger.

“It is a difficult moment but as you can see it’s not that the political system is unraveling. It is not. The solutions are being searched for,” Sotero said. “There is no expectation of a political collapse."

Read more:

Brazil's president says, 'I'm not guilty,' but even allies wonder if she can survive

Brazil's ruling party wonders how it lost the populist touch

Today’s coverage from Post correspondents around the world