Congress in Peru has voted not to impeach President Pedro Pablo Kuczynski over alleged corruption.
There were cheers and applause in the chamber as his supporters celebrated the news.
Mr Kuczynski’s opponents wanted to impeach him for allegedly receiving illegal payments from the Brazilian construction giant Odebrecht.
The president appeared in person in Congress during the 10 hours of debate to deny the allegations.
He accused the opposition of trying to stage a coup.
The motion to impeach required at least 87 votes to pass, but received only 79, with 19 against and 21 abstentions. Ten other lawmakers failed to attend the session.
Mr Kuczynski, 79, initially denied receiving any money from Odebrecht. However, he later denied receiving any illegal payments but admitted working on an advisory basis for the firm.
The payments by Odebrecht were made to Westfield Capital Ltd, a company owned by Mr Kuczynski. He said that although he owned the company, he was not its manager when it received the payments.
He says he had no involvement in the company’s management while he held ministerial roles in the government of former President, Alejandro Toledo (2001-06).
Critics of the impeachment vote said it was an attempted power grab by the right-wing opposition Popular Force party, which controls Peru’s congress. The party’s leader, Keiko Fujimori, lost the 2016 election to Mr Kuczynski by a slim margin.
Popular Force says Mr Kuczynski has repeatedly lied about his links to Odebrecht.
Peruvian prosecutors are also investigating allegations of illegal donations from the company to Ms Fujimori’s campaign.
Former President Toledo is currently fighting extradition to Peru over charges that he received bribes from Odebrecht. The country’s last President, Ollanta Humala, is in pre-trial detention along with his wife, Nadine Heredia, facing charges of laundering money from the company.