ROME — Italian Prime Minister Giuseppe Conte won the right to stay in power Tuesday night by narrowly prevailing in a confidence vote that staves off a mid-pandemic government collapse.

In the Senate vote, Conte persuaded just enough unaffiliated and opposition politicians to back the fragile government, a coalition that last week lost the support of one of its smaller parties. Conte survived — with a simple rather than an absolute majority — only because the defecting party, led by former prime minister Matteo Renzi, abstained from the vote.

The outcome gives Italy a degree of continuity but will also force Conte to govern with the slimmest of margins — a drawback for a coalition that is drawing up pandemic restrictions, handling vaccine distribution and trying to navigate a steep economic recovery.

Had Conte not won the confidence vote, it would have opened the door to a far greater degree of tumult. Italy could have wound up with an unelected unity government — or elections could have handed power to a group of far-right, anti-European parties.

Across Italy, voters are baffled about why the country endured a week of political chaos that left almost nobody better off. Renzi told Italians that his gambit to pull out of the government was based on policy disagreements over the economic recovery, but most saw it as an attempt to revive his political career and oust his rival, Conte. Now, his left-center party awkwardly sits outside of power, alongside the far right. And Conte, though weakened, is still standing.

Former Italian prime minister Enrico Letta said in a phone interview that Renzi’s move was “crazy, irresponsible, incomprehensible” — as well as politically suicidal. He said the government might be more stable in the long run by parting ways with somebody who had been agitating from the inside. But he said Italy’s system, so dependent on parliamentary approval, is punishing for minority governments.

“It’s almost impossible” to govern with a minority, Letta said. “In the next months there is the need to try to enlarge the [support].”

Analysts say Conte could still do that by luring additional independents and centrists, including potentially disenchanted members of Renzi’s party.

In the Senate vote, 156 voted in favor of the government and 140 against, with 16 abstaining.

The senators in Renzi’s party abstained from voting for or against Conte because party members didn’t want to fully join hands with the far-right League and the Brothers of Italy, the kind of sovereigntist parties that Renzi has spent much of his career attacking. Renzi created his party in 2019 by breaking away from the much larger Democratic Party, one of the current coalition members, and his former allies in that party were critical of his move.

Conte had spent the recent days making a case that it would be disastrous for a government to collapse in the midst of the pandemic, and said energy should be focused on the “urgent response” to the crisis. In a reference to Renzi, he said it was difficult to govern with “people who continuously place land mines in our path.”

Calling the crisis “incomprehensible,” Conte argued that politicians risked looking “like they have lost touch with reality.”

By hanging on, Conte has a chance to be Italy’s longest-serving leader since Silvio Berlusconi — even though he has no official party and was unknown to Italians until 2½ years ago. He has since charted one of the unlikeliest political careers in Europe. Initially lampooned as a powerless figurehead of a coalition dominated by the far right, he stayed on as leader in 2019 under a new, much different government — left-leaning and amiable toward Brussels. The fact that Conte once led a Euroskeptic, anti-migrant government seemed almost forgotten in his remarks to Parliament, when he called on support from “pro-European, liberal” forces.

Roberto D’Alimonte, a political science professor at Luiss Guido Carli University, said Conte has shown himself to be skilled at surviving political conflict.

“He has proven to be quite shrewd, for a man without a political party,” D’Alimonte said.

Stefano Pitrelli contributed to this report.