The party of Nawaz Sharif (centre) is in second place

Mr Musharraf told the Wall Street Journal there was a need to move forward to help bring about a stable democratic government in Pakistan.

US President George Bush called the vote a victory for Pakistani democracy.

Meanwhile the party of late former PM Benazir Bhutto says it is ready to form a coalition with Nawaz Sharif's PML-N.

A union of Ms Bhutto's Pakistan People's Party (PPP) with the PML-N would have more than half parliament's seats.

Will they be friends of the United States? I certainly hope so

US President George Bush

The main party backing President Musharraf suffered a heavy defeat, and correspondents say the president appears to be in a very difficult position.

If a new governing coalition manages to muster a two-thirds majority in parliament, it could call for Mr Musharraf to be impeached.

However, unofficial results suggest the two leading parties will not reach this total on their own, so would need to rely on support from other parties or independents.

US ally

But Mr Musharraf said that he would try to work with any new government.

NATIONAL RESULTS SO FAR PPP (Bhutto's party) : 87 PML-N (Nawaz Sharif): 66 PML-Q: (pro-Musharraf) 39 MQM (Sindh-based): 19 ANP (Secular Pashtuns): 10 MMA (Islamic alliance): 3 Others: 34 Source: Election commission

Can Musharraf survive?

"I would like to function with any party and any coalition because that is in the interest of Pakistan," he told the Wall Street Journal.

"The clash would be if the prime minister and president would be trying to get rid of each other. I only hope we would avoid these clashes," the president added.

Mr Musharraf was re-elected to the presidency last October, in a parliamentary vote boycotted by the opposition as unconstitutional.

He has been a major US ally in the "war on terror" but his popularity has waned at home amid accusations of authoritarianism and incompetence.

PPP leader Asif Ali Zardari invited Mr Sharif to join a coalition

President Bush, speaking in Ghana, said the elections were "judged as being fair, and the people have spoken. I view that as a significant victory".

When the new government is formed, he added, "the question then is: 'will they be friends of the United States?' and I certainly hope so".

'End of dictatorship'

At a press conference on Tuesday, Ms Bhutto's widower and the PPP leader, Asif Ali Zardari, said his party would "form a government of national consensus which will take along every democratic force".

"For now, the decision of the party is that we are not interested in any of those people who are part and parcel of the last government," he said, seemingly ruling out any coalition with the Pakistan Muslim League's pro-Musharraf wing, the PML-Q.

With votes counted in 258 out of 272 constituencies, the PPP has won 87 seats, according to the Election Commission of Pakistan.

HAVE YOUR SAY Perhaps Musharraf should leave Pakistan so that reforms can begin Clifford Power

The PML-N, or Pakistani Muslim League-Nawaz, is in second place with 66 seats so far.

The party's leader, former Prime Minister Nawaz Sharif, said earlier on Tuesday that he was prepared to discuss joining a coalition with Mr Zardari's party in order "to rid Pakistan of dictatorship forever".

The two parties so far have a combined total of 153 seats in parliament.

PML-Q chairman, Chaudhry Shujaat Hussain, told Associated Press Television News his party accepted the results "with an open heart" and was prepared to "sit on opposition benches".