Brazil's President Michel Temer has secured enough votes in the lower house of Congress to avoid facing trial on corruption charges.
Prosecutors had accused Mr Temer of obstructing justice and racketeering, which he has repeatedly denied.
Mr Temer, 77, could only face trial with the approval of two-thirds of the lower house.
Earlier on Wednesday, Mr Temer had tests in hospital for tests after his doctor diagnosed a urinary obstruction.
Only 233 deputies voted in favour of sending Mr Temer for trial, well below the 342 votes required, while 251 rejected the move.
Investigations against Mr Temer can now only resume once he steps down at the end of 2018.
Analysis: Temer gets away with it
Katy Watson, BBC South America correspondent, Sao Paulo
As the lawmakers cast their vote, emotions ran high. Amid shouts of "Out with Temer!", some said they were voting to take a stand against impunity. Others felt keenly that the president had to stay for the country's stability.
In the end, the result came as no surprise - President Temer may have the lowest approval ratings since polls began but people expected him to survive the vote and he has.
In recent weeks, Mr Temer has been busy making concessions to powerful lawmakers to secure support and that's paid off. For the second time in as many months, he's got away with it - but this time was clearly harder for him.
He didn't secure as many votes as when his allies blocked the first corruption charge in August. Some argue he'll now be a lame duck president, a weakened leader unable to pass key reforms ahead of next year's elections.
Last week, the congressional justice committee also rejected the charges against the president.
The charges stem from a corruption case involving the world's largest meat-packing firm, JBS. Mr Temer survived a similar congressional vote in August on bribery charges, but more deputies - 267 - voted in favour of a trial at that time.
He is currently facing the worst approval ratings in Brazilian history, but lawmakers seem prepared to protect him again, correspondents say.
Mr Temer became president last year following the impeachment of his predecessor, Dilma Rousseff.
She was found guilty of tampering with the government accounts in order to hide a growing deficit ahead of her re-election in 2014.