EVEN by the eccentric standards of the Brazilian congress’s lower house, it was an odd sight. On September 12th, shortly before midnight, Sílvio Costa of the Brazilian Labour Party clenched André Moura, a conservative deputy from the Christian Social Party, in a bear hug. By day, the two barely speak. Before Dilma Rousseff was suspended as president in May, pending impeachment over dodgy public accounts, Mr Costa led her government in the chamber. Mr Moura now does the same job for Michel Temer, Ms Rousseff’s deputy-turned-foe who succeeded her last month. So what lay behind the warm embrace?

It was to celebrate fellow deputies’ decision moments earlier, by 450 votes to ten, to expel a former speaker. Not long ago Eduardo Cunha (pictured), who belongs to Mr Temer’s centrist Party of the Brazilian Democratic Movement (PMDB), seemed omnipotent. His is now the latest head to roll in a bribery scandal centred on Petrobras, a state-controlled oil giant. The affair has engulfed Ms Rousseff’s Workers’ Party (PT) and its allies, which once included the PMDB. On September 14th prosecutors denounced her predecessor and the PT’s founder, Luiz Inácio Lula da Silva, as the linchpin of the scheme and charged him with bribe-taking (he denies wrongdoing). While less momentous than Ms Rousseff’s fall, and less resonant than Lula’s case, Mr Cunha’s fate matters deeply for politics.

Unlike Ms Rousseff, who was never personally accused of graft, Mr Cunha already faces trial for corruption. In March the supreme court indicted the then-speaker, who enjoyed parliamentary immunity from prosecution in lower courts, on accusations of accepting $5m from a shipbuilder for a contract to sell oil rigs to Petrobras. He was also charged with keeping secret Swiss bank accounts to stash illicit gains. Then in May, the justices also suspended Mr Cunha from congress. But criminal proceedings in the supreme court take years. While that was grinding on, only fellow lawmakers could end his mandate.

On paper, it was lying about the Swiss accounts to a parliamentary inquiry into the Petrobras affair—one that Mr Cunha had set up at the urging of the centre-right opposition—that cost him his congressional seat. The political background was popular disgust at his endless pursuit of self-interest with no fear of consequences. Many think he accepted the impeachment motion against Ms Rousseff so as to deflect attention from his own legal woes.

To a lot of Brazilians, the speaker epitomised their country’s flawed system. “Out with Cunha!” banners fluttered at anti-Rousseff rallies in the run-up to impeachment, and later at anti-Temer marches. As October’s local elections loom, deputies once loyal to Mr Cunha—in particular the centrão (big centre) block of small parties and backbenchers which he nurtured—ignored this fury at their peril. In the end even his own PMDB ditched him.

In February 2015, when Mr Cunha trounced Ms Rousseff’s candidate in the speakership contest, this outcome would have seemed fanciful. His crafty use of the rulebook prompted comparisons to Frank Underwood, the protagonist of “House of Cards”, a political TV drama. There was talk of a presidential bid in 2018.

For a man who has lost his immunity along with his congressional seat, a more likely prospect is a spell behind bars. His two indictments, plus two related ongoing cases, should land with Sérgio Moro, the crusading federal judge who oversees the Petrobras probe. Mr Moro is already trying Mr Cunha’s wife, Cláudia Cruz, for money-laundering. An arrest warrant for the couple, who deny wrongdoing, seems likely.

In practical terms, Mr Cunha’s departure from congress is good news for Mr Temer, at least for now. With its patron gone, the centrão should cause fewer headaches for the new administration as it trims public spending, a necessary first step to reviving Brazil’s economy and boosting Mr Temer’s political ratings.

A mountain of dirt

But fear of jail could prompt Mr Cunha to work with Petrobras prosecutors in exchange for leniency. That could spell trouble for an unpopular government. Over a quarter-century, Mr Cunha is thought to have amassed dirt on politicians of all hues, maybe including Mr Temer’s inner circle (though probably not the president himself, to whom he was never close.)

Mr Cunha denies rumours that his lawyers are probing such a deal. “Only criminals strike plea bargains,” he told reporters, adding that he was no such thing. He pledged instead to publish a memoir telling how Ms Rousseff’s impeachment was stitched up. Still, even a remote chance of a Cunha testimony will worry lawmakers. Mr Cunha may be gone but his shadow will haunt them.