The result, boosted by a higher than expected turnout despite the coronavirus pandemic, comes as a surprise after the Socialists had lost most of their advantage in recent opinion polls, and means Portugal will have a stable government to oversee the application of EU pandemic recovery funds.

The vote was called in November after Costa's hard-left former Communist and Left Bloc allies joined the right in striking down his minority government's budget.

The two far left parties paid the price, losing more than a half of their seats, according to exit polls.

After last week's opinion polls Costa had himself acknowledged that Portuguese did not want to give him a full majority and said he was prepared to strike alliances with like-minded parties, which is no longer necessary.

"An absolute majority doesn't mean absolute power. It doesn't mean to govern alone. It's an increased responsibility and it means to govern with and for all Portuguese," Costa said in his victory speech.

Before the final results came in, Costa said the party had won 117 or 118 seats in the 230-seat parliament, up from 108 won in the 2019 election, and his supporters erupted in loud celebrations, singing old revolutionary anthem "Grandola" and waving flags.

Costa, who came to power in 2015 in the aftermath of a 2011-14 debt crisis, has presided over a period of steady economic growth that helped shrink the budget deficit and even eke out a small surplus in 2019, before the pandemic struck.

Still, Portugal remains western Europe's poorest country and relies on EU pandemic recovery funds.

Economist Filipe Garcia, head Informacao de Mercados Financeiros consultants in Porto, said investors would likely appreciate Costa's new strong mandate, given the government's record cutting of the budget deficit.

"Furthermore, the Socialists will not need to compromise (with other parties), which guarantees stability and a clear line of action. The biggest challenge will be to promote potential growth," he said.

The centre-right Social Democrats came a distant second at below 30% of the vote, according to provisional results, against the Socialists' around 42%.

The far-right Chega emerged as the third-largest parliamentary force making a big leap from just one seat in the previous legislature to at least 11.

A stable government would bode well for Portugal's access to a 16.6-billion-euro ($18.7 billion) package of EU pandemic recovery aid and its success in channelling funds into projects to boost economic growth.

With more than a tenth of Portugal's 10 million people estimated to be isolating due to COVID-19, the government had allowed infected people to leave isolation and cast ballots in person https://www.reuters.com/world/europe/portugal-grapples-with-in-person-voting-people-with-covid-2022-01-29, and electoral officials donned protection suits in the afternoon to receive them.

Turnout was on track to beat 2019's record low 49% participation.

As in many European countries, infections have spiked, although vaccination has kept deaths and hospitalisations lower than in earlier waves.

(Writing by Andrei Khalip, additional reporting by Miguel Pereira; editing by Peter Graff, Chizu Nomiyama and Michael Perry)

By Sergio Goncalves, Catarina Demony and Andrei Khalip