In this Nov. 11, 2017, file photo, Peruvian President Pedro Pablo Kuczynski attends a multillateral meeting in Danang, Vietnam. (Jorge Silva/Pool photo via AP)

Peru’s president, Pedro Pablo Kuczynski, survived an impeachment vote Thursday night after 10 members of a hard-right opposition party decided at the last minute to break ranks and abstain rather than vote for the measure.

Seventy-eight representatives voted in favor and 19 against. That came short of the necessary two-thirds supermajority, 87 votes, required in the 130-member single-chamber legislature.

The surprise result, just after 11 p.m. and following a marathon parliamentary session that started at 9.30 a.m., left the Popular Force party of Keiko Fujimori, which dominates Congress, licking its wounds after pushing hard for the impeachment.

However, it arguably also leaves Kuczynski as a lame-duck leader, just 17 months into his five-year term. Meanwhile, ordinary Peruvians, continue to be disgusted with the entire political class, with both Congress and the president showing rock-bottom approval ratings.

What may have swayed the result was the president’s tough stance, announced the night before, that if he were impeached, neither of his two vice presidents would fill his shoes, effectively forcing new elections, a scenario that few sitting members of Congress were thought to welcome.

Peruvian opposition leader Keiko Fujimori speaks to the press in Lima, Dec. 7, 2017. (Luka Gonzales/AFP/Getty Images)

Kuczynski’s opponents produced documents last week showing that Odebrecht, the Brazilian construction giant at the heart of Latin America’s largest corruption scandal, made payments of nearly $800,000 to his investment banking firm, Westfield Capital. Some of the payments occurred during his previous stints as economy minister and prime minister, while Odebrecht was winning major public contracts.

The sprawling Odebrecht scandal, in which the company has admitted paying nearly $800 million in bribes to officials in more than a dozen countries across Latin America to secure public contracts, has rocked the region and led to indictments and even jail terms for numerous powerful ­people.

It helped drive the impeachment of Brazilian President Dilma Rousseff, technically based on the alleged mismanagement of government accounts, and has resulted in prison sentences for two sons of a recent president of Panama, the vice president of Ecuador and a former deputy transport minister in Colombia, among others.

But outside Brazil, Peru has been the hardest-hit country. One former president, Alejandro Toledo, is fighting extradition from the United States over allegations he took $20 million in bribes, and another, Ollanta Humala, is in pretrial detention in Lima after allegedly receiving illegal campaign funding from Odebrecht.

Nuns shout slogans against Keiko Fujimori, daughter of jailed former president Alberto Fujimori, blaming her party for corruption charges against President Pedro Pablo Kuczynski, in Lima, Peru, Saturday, Dec. 16, 2017. The poster reads in Spanish, “Fujimori never again.” (Martin Mejia/AP)

Kuczynski, a center-right economist and former U.S. citizen who worked in the United States at the World Bank and the International Monetary Fund before launching his political career, initially denied any link to Odebrecht. He later said he had cut ties to Westfield upon assuming office and that the payments were for consulting work performed by a former business partner.

The opposition-controlled Congress, however, promptly voted 93 to 17 to initiate impeachment proceedings. After Kuczynski’s appearance Thursday morning to defend himself, the legislature began the debate that resulted in the final vote.

Critics of the effort to remove Kuczynski saw the vague charge and the swift pace of proceedings as violations of due process. They accused the hard-right Popular Force party, which is led by Keiko Fujimori, daughter of jailed 1990s strongman Alberto Fujimori, of using the controversy as a pretext for an unconstitutional power grab.

The impeachment drive came just as anticorruption prosecutors are making headway in their investigations of Fujimori’s murky finances, and it coincided with Popular Force’s ongoing attempts to oust the attorney general and several members of Peru’s Constitutional Court on grounds that have been ridiculed by independent legal scholars.

The effort followed months of tension between Popular Force and the Kuczynski administration, with the opposition party using its congressional muscle to impeach several ministers while also blocking ethics investigations of its own members for a long list of alleged irregularities that include money laundering, extortion and fabricating high school diplomas.

Pedro Cateriano, a former prime minister and professor of constitutional law, describes Popular Force’s maneuvers as an attempted “coup.” He is urging ­Kuczynski to invoke the democratic charter of the Organization of American States, which allows the multilateral group to suspend member nations when there is a breach of democratic order.

“The situation is extremely dangerous. If Kuczynski is impeached, the cost for the country will be huge,” Cateriano said. “The president appears to have had a conflict of interest. But what Congress should be doing is first starting an investigation, with a presumption of innocence, to get to the bottom of the matter.”

Diego García-Sayán, a former justice minister and president of the Inter-American Court of Human Rights, agreed. He said the impeachment push must be viewed in the context of an opposition drive to stack the Constitutional Court, the ultimate arbiter of any conflict between the executive branch and the legislature.

“This is an attack on Peru’s democratic institutions,” García-Sayán added.

Fujimori, 42, narrowly lost to Kuczynski, 79, in last year’s presidential election. Since then, she has barely spoken in public while exercising tight control over Popular Force’s congressional bloc from behind the scenes. Thanks to Peru’s electoral-list formula, the party won 73 of the 130 legislative seats despite taking 36 percent of the popular vote.

She also has failed to clearly renounce her father’s 1990-2000 administration, in which he presided over the disappearance of billions of dollars from public coffers, shuttered Congress and the courts and directed clandestine death squads against suspected subversives.

Yet Fujimori is feeling the heat over claims that Odebrecht gave Popular Force millions of dollars in under-the-table donations, and that separately she laundered $15 million. Unlike the money that Kuczynski’s company received, the income was not declared, nor were taxes paid on it.

Prosecutors raided Popular Force’s offices this month and seized documents that they allege show “parallel accounting.”

An Oxford- and Princeton-educated former Wall Street investment banker, Kuczynski has seen his approval ratings plummet from the high 70s to the low 20s since his inauguration. Many voters have been frustrated by his failure to confront the opposition’s hardball tactics.

On the other hand, polls show that nearly 70 percent of Peruvians say the Popular Force party is “abusing” its congressional majority, while Fujimori’s approval rating also has fallen five points in the past quarter to 33 percent.

William Branigin in Washington contributed to this report.