Pakistani election winner Nawaz Sharif was in talks Sunday to form a new government, as US President Barack Obama said Washington was ready to work with Islamabad "as equal partners".
Obama welcomed the "historic, peaceful and transparent transfer of civilian power" in Pakistan, where Sharif's two biggest challenges are likely to be fixing the shattered economy and tackling Islamist militancy.
"My administration looks forward to continuing our cooperation with the Pakistani government that emerges from this election as equal partners in supporting a more stable, secure, and prosperous future for the people of Pakistan," Obama said in a statement.
Partial, unofficial results from Saturday's election represented a stunning comeback for the wealthy 63-year-old tycoon who was deposed as prime minister in a 1999 military coup and spent years in jail and exile.
Sharif appears to have done well enough to rule out the prospect of a weak coalition, as the party of former cricket star Imran Khan achieved its own breakthrough on an anti-corruption platform that resonated with younger voters.
Khan's party also looked set to take over the provincial government in the restive northwest, where he has vowed to end US drone strikes.
Taliban violence marred the election campaign with attacks killing more than 150 people, including 24 on polling day.
While Sharif has voiced support for peace talks with the Taliban, he has been less vocal against US drone strikes than Khan, and is considered a pragmatist with whom Washington can work.
India's Prime Minister Manmohan Singh wrote on his official Twitter page that he hoped to chart "a new course for the relationship" between the nuclear-armed neighbours.
Afghan President Hamid Karzai called on the incoming government to help negotiate an end to the Taliban insurgency that has ravaged his country since 2001.
And UN Secretary-General Ban Ki-moon applauded "the courage and determination of political parties and election workers to engage in the electoral process despite the challenging security situation", according to a spokesman.
Pakistan, which has had three coups and four military rulers, is marking the first time that one elected civilian administration will hand power to another after a full term in office.
TV projections suggested no single party would win an absolute majority in the 342-seat national assembly.
But Sharif's centre-right Pakistan Muslim League-N (PML-N) was well ahead with more than 115 of the chamber's 272 directly elected seats, according to various projections by private channels.
Sartaj Aziz, a senior PML-N official and former cabinet minister, said Sharif was in talks Sunday with some independent MPs to get them on board and in discussions to work out "a few key portfolios" in the cabinet.
The election was defined by the tanking economy, an energy crisis that causes power cuts of up to 20 hours a day, the unpopular alliance in the US-led "war on terror" and chronic corruption.
Sharif has vowed a pro-business agenda to revive the feeble economy for what will be his third term as prime minister, a record in Pakistan, following two tenures in the 1990s.
Asked how his time in prison and exile had changed him, Aziz said it had "made him more thoughtful".
Khan's Pakistan Tehreek-e-Insaf (PTI) was neck-and-neck with the outgoing Pakistan People's Party on around 25 to 30 seats, a remarkable achievement given that it only won one seat previously, in 2002.
Besides the national assembly, voters also elected four provincial assemblies and Khan's party emerged on top in Khyber Pakhtunkhwa, putting PTI on track to form a government on the frontline of the war against the Taliban.
Khan welcomed the high turnout as a step forward for democracy but alleged vote-rigging in a televised statement from the hospital bed where he is laid up with a fractured spine following a fall at an election rally last week.
"They placed election staff and administration officials for rigging at various places. Rigging was done in Punjab, in Karachi it was visible to everyone and in Sindh also," he said.
Khan declared he would go into opposition and said that if his party forms a government in Khyber Pakhtunkhwa, they would turn it into a "model province".
"I want to assure that the change has come in Pakistan," he said.
The Bhutto clan's PPP, which led the outgoing coalition, was heavily defeated over its record of ineffectual administration over the past five years.
Sharif gave a victory speech late Saturday to hundreds of jubilant supporters at PML-N headquarters in Lahore.
"I appeal for all parties to come to the table and sit with me and solve the country's problems," he said, after nearly 60 percent of the 86-million electorate voted.
Pakistan's largest domestic observer mission, The Free and Fair Election Network, said Sunday that the polls were "relatively fair" despite some irregularities and violence at the polling stations.