In the week that Brazil’s deeply unpopular president, Michel Temer, survived a congressional vote that could have seen him face criminal charges of racketeering and obstruction of justice, a rap video called I’m Happy (I Killed The President) 2 has become a viral hit.

The song by Gabriel o Pensador (“Gabriel the Thinker”), 43 – a rewrite of an earlier hit the rapper released 24 years ago, during the impeachment of then president Fernando Collor – has been watched more than 3m times on YouTube.

The threat implied in the title is not literal, it goes on to explain. “But if all the corrupt died suddenly / It would be all different, there would be so much money left,” raps O Pensador – whose real name is Gabriel Contino.

However, most Brazilians paid little attention to Wednesday’s vote, unlike in 2015 and 2016, when Temer’s predecessor Dilma Rousseff faced enormous street demonstrations calling for her impeachment over a spiralling graft scandal and failing economy.

Just a few thousand marched joined an anti-Temer protest in Rio on Tuesday. Police easily dispersed them with clouds of teargas.

After Wednesday’s vote, the president thanked lawmakers for their support. “The economy has returned to growth after the biggest recession in our history. This is the biggest work of my government,” he said.

The reality is more complex. The president’s mandate survived because Brazil did an uneasy deal with itself. Lawmakers bargained their support, the population shrugged, and financial markets decided not to lose another president – Rousseff was ousted in 2016 for breaking budget rules – just as Brazil’s economy is limping out of a recession.

“There is an issue of avoiding the worst-case scenario, which would be an economic meltdown,” said Marcos Troyjo, an adjunct professor of international relations at Columbia University.

Gabriel O Pensador’s video has been viewed more than 3m times on YouTube

Temer, 77, was first charged with corruption in June, but won a first congress vote weeks later to avoid being suspended for trial. Now he will probably survive in office until new elections in 2018. But the cost was high.

To please a powerful agribusiness bloc in congress, Temer reduced Amazon protection and discounted fines for environmental offences. Despite Brazil’s soaring deficit and his own austerity programme, he also bought support by cancelling the privatisation of São Paulo’s domestic airport, lowering payments for fines and interest on overdue taxes, discounting payments of overdue taxes and agreeing extra money for lawmakers’ projects in their home states. All at a potential cost of $10bn since June, the Estado de S Paulo newspaper calculated.

Many Brazilians were appalled.

“He is terrible. He bought lawmakers so nobody would vote against him,” said Douglas Corrêa, 24, a Rio street cleaner.

But the congressional vote put an end to a political crisis which began in May with the release of a wiretap of a compromising conversation the president held during a secret late-night meeting with a powerful executive. The evidence against Temer and his cronies included $152,000 in a suitcase handed to a key Temer aide filmed scuttling out of a São Paulo pizzeria and $15m in cash found in an apartment linked to a key minster and friend – since jailed.

“Brazilians today feel repulsion for politicians, for the congress,” said Ricardo Ismael, a professor of political science at the Pontifical Catholic University of Rio de Janeiro.

But as Temer noted, the economic numbers are up, even if most Brazilians are yet to feel the benefit, with the stock market surging, and inflation, interest rates and unemployment all falling. His unpopular reforms, such as a 20-year cap on public spending and a loosening of outdated labour laws, have been credited for some of this growth. Powerful financiers had concluded the charges were going nowhere and wanted to move on.

“The president is a long way from having admirers among bankers, who have no doubt his government is corrupt. But for this group pragmatism is king,” economic columnist Raquel Landim wrote in the Folha de S Paulo newspaper on Thursday.

The irony, said José Álvaro Moisés, a professor of political science at the University of São Paulo, is that while Temer’s liberal economic policy helped save his mandate, he may no longer have enough support to pass his intended landmark reform – a politically explosive overhaul of a generous pension system the World Bank called “unsustainable”.

“The congress base will impose more and more difficult conditions,” Moisés said. “Nobody talks any more about pension reform in the way it was originally proposed.”