Portugal's governing Socialist Party has admitted defeat in the general election.
Socialist leader Jose Socrates said he accepted responsibility for the defeat and resigned as head of his party.
The victorious centre-right Social Democrats (PSD) led by Pedro Passos Coelho are expected to form a majority with the conservative CDS.
The new government must implement a demanding austerity programme as a condition for an EU bail-out.
Exit polls gave the PSD between 37% and 42.5% of the vote, ahead of the Socialists who scored between 24.4% and 30%.
"These are clear results which the Socialist Party wants to recognise. All the results point to a win for the PSD and a defeat for the Socialists," Economy Minister Jose Vieira da Silva said.
Announcing his resignation to party supporters in Lisbon, Mr Socrates said: "This defeat is entirely mine and I want to assume full responsibility for it.
"I feel it is necessary to open a new political cycle that is able to prepare a consistent alternative. I want to give the Socialist Party the space to discuss its future and select a new leadership."
All the main parties are backing the 78bn euro ($116bn; £70bn) bail-out, which requires tough austerity measures amid a faltering economy and a debt crisis.'Difficult period'
As his victory became clear, Mr Passos Coelho said he would do "everything possible" to make sure Portugal honoured the terms of the bail-out.
"I want to guarantee to those who are watching us from abroad that Portugal does not intend to be a burden for the future to other countries that lent us the means that we needed today to face up to our responsibilities," he said.
Earlier, as he cast his own vote, he acknowledged that the country faced "a very difficult period for the next two or three years".
He added: "I am sure that we will make the necessary change and Portugal will achieve new prosperity with economic growth."
Mr Socrates resigned as prime minister in March, triggering the early elections after the opposition in parliament rejected his minority government's fourth austerity package in less than a year. He then acted as caretaker prime minister.
Portugal is faced with unemployment of more than 12% and an economy that is expected to contract by 2% this year and next.
Mr Passos Coelho suggested this week that he was the preferred candidate of donors to the bail-out fund.
"We are going to cut state waste and excesses while finding a way for the needy to get what they need," he told supporters.
Before the vote, Mr Socrates accused the Social Democrats of pursuing a "radical right-wing agenda" and criticised Mr Passos Coelho for lacking experience in government.
The terms of the bail-out call for tax increases, a freeze on state pensions and salaries, and cuts in unemployment benefits.
"The road with this package is long and filled with reforms which may be politically difficult to pass," Diego Iscaro, an economist at IHS Global Insight, told Reuters news agency.