Four seats in the 230-member assembly were yet to be declared but Costa, who leads the Socialist party (PS), has begun the process of forming a government with outside support.
The PSD is polling at under 30% and is expected to lose seats, while the Socialists are seen winning more than in 2015.
Costa's government has been praised by Brussels and at home for combining fiscal discipline with measures to promote growth after recession and the austerity of Portugal's 2010-14 debt crisis.
Mr Costa said he was delighted with the result and added that voters had shown they wanted stability.
The election could give Costa another potential government ally in addition to the Left Bloc and Communists that propped up his previous government as polls suggest the upstart People-Animals-Nature party (PAN) could capture up to four percent of the vote.
The amount of all asylum-seekers into Germany and France, together numbering over 300,000 final year, dwarf Portugal's complete, which hardly reached four characters.
Ana Andrade, an analyst at The Economist Intelligence Unit, said a political alliance on the left was likely, with Costa probably having to make some concessions on public spending.
The main question now is who Prime Minister Antonio Costa will pick as allies to stay in power.
Portuguese President Marcelo Rebelo de Sousa casts his vote in Celorico de Basto, northern Portugal.
Costa toppled the Portugal Ahead coalition with his anti-austerity campaign and a noncoalition alliance with far-left parties including the Left Bloc, the Communist Party and the Greens.
The Socialists (PS) took 36.65% of the vote, followed by the centre-right Social Democrats (PSD) with 27.9%, according to near-total results released by the interior ministry early on Monday.
Leaders for the Left Bloc and the Communists each acknowledged that they had no objections to Costa being nominated as premier and had been open to negotiate if the Socialists committed to making improvements to the lives of group. "We are going to have the selection to resolve our spot counting on the PS' alternatives, on its finances devices and the tell material of its legislative proposals".
The Socialists' popularity had been hit by a string of scandals, including accusations of nepotism and a suspected cover-up of weapons theft at a military base. Portugal is holding a general election Sunday in which voters will choose members of the next Portuguese parliament. The economy is on course to grow 1.9% in 2019, above the European Union average, helped by export growth and a booming tourism industry.
"We take the result with democratic humility", said Cristas, in a short statement to journalists at the party's national headquarters in Lisbon, as election results emerged. But those seats are no longer ample for the Socialists to govern with them on my own. "I still wish it was more, because the country needs to move quickly to tackle the climate emergency", PAN supporter Paulo Santos, 43, said at the party's evening rally. Right-wing populists managed to win one seat in parliament - a first in a country where right-wing populist parties play no significant role.