The governing party emerged victorious from a snap election, but without the majority needed to avoid forming a coalition in the fractious parliament.LISBON — Portugal’s governing Socialist Party was victorious in snap elections on Sunday, winning the most seats in parliament, though it didn’t secure the majority it had sought to govern without forming a coalition.The result brought relief to Prime Minister António Costa, Portugal’s leader of the last six years, who has been popular for managing the country’s response to the pandemic but also faced questions about his stewardship of the economy.Mr. Costa — who is expected to be tasked by Portugal’s president to form a government — would still need to create a coalition in a fractious parliament which only last November would not pass a budget, setting the stage for Sunday’s snap election.“It will be necessary to wait and see how the coalitions emerge — whether on the left or on the right — and this may be more important,” said Marina Costa Lobo, a political scientist at the University of Lisbon.With 98 percent of the vote counted, Portugal’s Socialist Party had taken 42 percent of ballots, slightly lower than its share in the last election in 2019. The center-right Social Democratic Party, or P.S.D., had roughly 28 percent of the votes.The snap election was called in November after the budget dispute, which involved defections from Mr. Costa’s left-wing partners.At first, Mr. Costa bet on the possibility of increasing his party’s seats in Parliament — saying at one point he sought an absolute majority there — and polls at the start of the campaign showed the Socialists gaining. As Election Day neared, however, their prospects began to dim, and some polls showed their lead slipping, only to make a turnaround Sunday.For Maria Júlia Boanova and António Boanova, a retired couple in their 80s, Mr. Costa’s management of the health crisis was the key factor in their vote on Sunday. Both became ill with Covid-19, and Mr. Boanova was at one point hospitalized in the public health system, something that shored up his support of the government.“Everything was spot on — doctors, nurses, everything,” he said. “Politicians never gave me much, but the ones who at least gave me something were the Socialists.”Mr. Costa was depending on good will from his management of the pandemic, which has often been the envy of other European nations.Though Portugal was devastated by early waves of the coronavirus in 2020, the country embarked on an aggressive vaccination campaign that left more than 90 percent of the population vaccinated, among the highest rates in the world. To make that happen, the government enlisted Henrique Gouveia e Melo, a former submarine squadron commander who ultimately became the highly popular face of the government’s vaccination effort.Portugal’s Prime Minister, Antonio Costa, arrives for the electoral night in Lisbon on Sunday.Miguel A Lopes/EPA, via ShutterstockMany Portuguese also applauded Mr. Costa for avoiding austerity measures that were adopted by his conservative predecessors after the 2008 financial crisis, like tax increases and public sector wage cuts. Popular backlash to the belt-tightening paved the way for Mr. Costa’s rise to power in 2015.Still, Ms. Costa Lobo, the political scientist, said public opinion research showed that Portuguese voters remain concerned about the economy in addition to the pandemic.“There is also fear and declining economic expectations for the near future and some economic pessimism,” she said.In the upscale Lisbon neighborhood of Lapa, Vladym Pocherenyuk, 49, who works at an embassy in the capital, said he had soured on the Socialists after watching them in power for the past six years. He cast his vote for a small libertarian party called Liberal Initiative.“We still see many young and qualified people having to go abroad to earn a decent salary, like my daughter who is working in Dubai,” he said. “I struggle just to get to the end of the month with what I’m paid, and that is the situation for most people.”Experts agree that the new government’s chief concern will be passing the budget again.Portugal is awaiting a new infusion of recovery funds from the European Union worth roughly 16.6 billion euros, or about $18.5 billion, and seen as crucial to stabilizing the country’s economy as it recovers from the pandemic. But the money is contingent on Portugal meeting a variety of targets, including lowering its budget deficit.Sunday’s election also brought good news for Portugal’s right-wing party, Chega, which won at least 7 seats, on track to be parliament’s third largest party.Supporters of the center-right Social Democratic Party monitoring their phones in Lisbon on Sunday.Ana Brigida/Associated PressThe party, which was founded in 2019 by defectors from the P.S.D., secured its first seat in Parliament that year. It has since become a fixture in Portuguese politics, supporting candidates known for provocative statements about race relations and expressing nostalgia for Portugal’s former dictator, António de Oliveira Salazar.Experts say it remains unclear how much influence the party will have, however. The center-right P.S.D. has said it isn’t interested in joining forces with the party, limiting the influence that Chega could have in a future government.Cátia Bruno contributed reporting from Lisbon. More