The general election was the first since Portugal exited an international bailout last year. Victory for the government was unthinkable just a few months ago with polls giving a solid lead to Socialists who promised to ease back on austerity and give more disposable income back to families.
It comes amid signs that voters elsewhere in Europe appear resigned to austerity. In Greece, voters gave Alexis Tsipras a new mandate last month to implement tough measures he had once rejected; and in Spain, Prime Minister
Mariano Rajoy's People's Party leads polls before a Dec. 20 election.
Nicholas Spiro of Spiro Sovereign Strategy said the election underlined the weakness of the Socialist Party (PS) challenge in a country where unemployment remains high at 12.4 percent and many Portuguese have felt no benefit from the fledgling recovery.
"This election was a defeat for the PS more than anything else," he said.
President Anibal Cavaco Silva will have the task of naming the next prime minister after talking with all political leaders, which he is expected to start in coming days.
The constitution does not specify how the president should pick the winner, whether by the number of votes or the number of lawmakers elected to parliament. The son of a country doctor who grew up in Angola, Passos Coelho has once acknowledged that he wanted "to go beyond the Troika", that is demands by Lisbon's bailout creditors, to swiftly reconquer investor confidence.
Portugal's economy returned to slow growth last year after a three-year recession and is now expanding by 1.6 percent. Going into the election, investors were broadly confident that Lisbon would pursue its reforms. Portuguese bond yields held just above seven-week lows on Friday.