The 4-3 decision gives Temer some breathing room, but he still faces a corruption investigation and street protests that threaten to force him from office before the next presidential elections in October 2018.
The prospect of a second Brazilian president being forced out of office in less than a year has unsettled markets and investors.
The Brazilian economy has started to crawl out of the worst recession on record, thanks in part to Temer’s efforts to push unpopular austerity measures through Congress.
But with the corruption investigation heating up, it is not clear he will have the political backing to get key pension and other measures approved.
“Pension reform is certainly at risk, and as Temer continues to struggle for his survival in coming months some items on the agenda may be slowed,” Christopher Garman of the Eurasia Group consultancy wrote in a report.
Nonetheless, he said other reforms would likely move forward.
The latest scandal broke last month. A secret recording surfaced on which Temer and Joesley Batista, the president of a multinational food processing company named JBS, can be heard talking about paying bribes.
Temer’s approval rating is in the single digits and the Supreme Court has opened an investigation into alleged corruption and obstruction of justice.
If Temer is ousted, power is handed to Congress, which will have up to 30 days to choose a caretaker president until new elections.