Portugal's centre-right coalition government has won the country's general election behind an improving economy that weathered austerity measures but appears to have fallen short of a crucial outright majority in parliament.
With 99 percent of districts reporting on Sunday, the government had 37 percent compared with 32 percent for the main opposition centre-left Socialist Party. Smaller, leftist parties made up the rest.
The result means the government is likely to be outnumbered in the 230-seat chamber by left-of-centre MPs who could block its policy proposals.
A period of political instability could ensue, making investors once again nervous about the eurozone's ability to sort out its economic problems.
Incumbent Prime Minister Pedro Passos Coelho said his government is determined to abide by the eurozone's fiscal rules.
Coelho said he is willing to compromise with opposition parties to achieve the "essential goal" of reducing national debt.
"Times haven't been easy, and the times ahead will be challenging," he said.
Portugal needed a $87bn bailout in 2011 amid the eurozone's debt crisis.
The government complied with a German-led austerity plan to restore financial health, by cutting pay, pensions and public services and increasing taxes that brought large street protests and strikes.
The austerity policies helped propel Portugal into a three-year recession, and the socialists were optimistic they would benefit from a backlash against the government.
Socialist leader Antonio Costa conceded defeat but warned that the government must change its conduct now that it has lost its outright majority in parliament.
"The government has to understand that things are different now," Costa said, adding that he would not seek to make the country ungovernable.
The economy is improving, allowing the government to argue that austerity is paying off.
The economy grew 1.5 percent in the first half of this year compared with the same period in 2014.
The unemployment rate has fallen from a record 17.7 percent in 2013 to 12.3 percent last July.
'Something's got to change'
Portugal shunned the kind of radical alternatives that have emerged in Europe in recent years, such as Greece's Syriza and Spain's Podemos, which have challenged mainstream parties from the far left.
The Portuguese have a traditional preference for moderate parties, and voters apparently feared knocking the long-awaited economic recovery off track.
A handful of grassroots anti-austerity parties barely registered in the ballot.
The government, made up of the Social Democratic Party and its junior partner, the Popular Party, united the right-of-centre vote while the left-of-centre vote was more fragmented, comprising the socialists, the Left Bloc - with at least 10 percent, its best-ever result - and the Communist Party, with eight percent.
The election outcome "wasn't so much a victory for the government as a defeat for the socialists," said Antonio Barroso, a London-based analyst with the Teneo Intelligence political risk consulting group.
The Socialist Party promised to start easing the tax burden and speed up growth through domestic consumption, but the Socialists had a credibility problem because they led Portugal to the brink of bankruptcy four years ago.
Teresa Godinho, a middle-aged psychologist voting at a polling station in Lisbon's suburbs, said she did not entirely agree with the government, but voted for it because there were no other viable options.
"I lost my trust in the Socialist Party when they left us nearly bankrupt," she said.
But Tiago Amaral, a salesman unemployed for the past 18 months, said he opted for the Socialists because he was frustrated.
"All I know is something's got to change," he said.