Michel Temer © AFP

The first thing visitors landing at Brasília airport see are giant advertisements for House of Cards, the US television series whose main character is political arch-operator Frank Underwood.

“Choosing money over power, a mistake just about everyone makes,” one of the signs quotes Underwood as saying.

But in a capital that has seen more than its share of political intrigue over the past year, one politician at least is showing he has little need of lessons from Hollywood on Machiavellianism — President Michel Temer.

Late on Friday, the Brazilian leader survived his most critical test since he was brought to power last year by the impeachment of former leftist president Dilma Rousseff — a landmark hearing in Brazil’s electoral court.

The decision by the court, known as the TSE, concerned a long-running case that started before the impeachment and alleged that Ms Rousseff’s campaign in the 2014 elections used illegal funding. Had the court decided in favour of the case, Mr Temer, who ran on Ms Rousseff`s ticket as her then vice-president, would have been ejected from power. In the event, the seven-member court ruled 4-3 that it did not have enough evidence to terminate the Rousseff-Temer joint ticket.

“For the president, it’s a very big relief, and it will give him the opportunity to plan his next steps,” said Thiago de Aragão, director of strategy at political consultancy Arko Advice.

But Mr Temer still faces a potentially devastating criminal investigation and — analysts warn — a battle to hold his coalition government together and maintain the momentum behind an ambitious reform programme designed to help rescue Latin America’s largest economy from its worst recession in history.

A recording released last month allegedly showed him discussing bribes with Joesley Batista, the billionaire former chairman of meatpacker, JBS.

As part of a related plea bargain with JBS executives, police filmed one of Mr Temer’s former special advisers, congressman Rodrigo Loures, receiving a suitcase of money from the company. Now in jail, there is speculation that Mr Loures could agree to a plea bargain in exchange for leniency. Mr Temer denies all allegations.

Analysts also expect the attorney-general’s office to indict the president in the supreme court. But under Brazil’s constitution, a sitting president can only be tried by the supreme court if two-thirds of congress approves.

This will make it more important than ever for the president to hold his unwieldy coalition in congress together. The most serious potential rupture could come from the main coalition partner of his ruling PMDB party in congress, the pro-business PSDB, some of whose members are growing uneasy at the allegations against Mr Temer. “The PSDB feels they have lost too much political capital supporting Temer and they’ve got nothing in return,” said Carlos Melo, political analyst at Insper, a business university in São Paulo.

For investors, most important is what will happen to Mr Temer’s reform programme, including his proposed overhaul of the country’s fiscally unsustainable pension system. “We have to begin talking again with congressmen to get the pension reform back on track,” said Arthur Maia, a Temer ally and rapporteur of the bill in the lower house. “The Brazilian state needs to do these reforms independent of who is president,” he said.

While the TSE decision has given him a break, Mr Temer will still need to summon all of his House of Cards skills to survive, analysts say.

The decision has already caused waves. The majority of the judges, including two recent Temer appointees, decided to ignore key evidence from an investigation into political corruption at state-owned oil company, Petrobras, and one of its main contractors, Odebrecht. In a heightened political environment, this could sour public opinion. “The crisis of legitimacy that has devastated our political system appears to have now spread to one part of the justice system,” wrote Oscar Vilhena Vieira, a lawyer, in a column in Folha de S.Paulo newspaper.

But even his political enemies admit few know Brasília as well as Mr Temer. The 76-year-old was three times head of the lower house of congress.

“Temer has not been dropped [by the ruling coalition] because they don’t have anyone else who has his capacity to articulate a strategy with congress,” said senator Gleisi Hoffmann, the national leader of the opposition Workers’ party, or PT, in the senate. “He has spent his entire life doing this.”

Copyright The Financial Times Limited 2018. All rights reserved.