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.
Temer, 76, was the vice-presidential candidate alongside Rousseff in 2014, but Rousseff was impeached last year
for illegal fiscal maneuvers aimed at hiding the budget shortfall. She has denied the allegations.
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.
In a plea deal, Batista said Temer condoned the payment of hush money to silence a jailed legislator. Temer has denied the allegations
and says the recording was doctored.
But the scandal -- just the latest development in the long-running "Operation Car Wash" corruption investigation that has implicated dozens of politicians from across the political spectrum -- prompted new street protests
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.
In the meantime, the Car Wash investigation has already engulfed the major political players and business leaders
-- leaving the electoral field wide open.