"We will work together to form the government in the centre and in the provinces," Mr Sharif, head of the Pakistan Muslim League - Nawaz (PML-N), said at a joint news conference with Mr Zardari.

He said the two parties had agreed that the country's chief justice, sacked by President Musharraf in November, should be immediately reinstated.

Mr Zardari said there was "a lot of ground to cover" between the two parties, but "in principle, we have agreed to stay together".

Doubts remain about who will emerge as a possible prime minister.

Mr Zardari has ruled himself out for the role, despite his party's success at the election.

He has said his PPP party will choose another candidate to lead a coalition government.

Mr Zardari, a deeply divisive figure in Pakistani politics who has spent several years in prison on corruption charges, is not an MP and is therefore not currently eligible to serve as prime minister.

The party backing President Musharraf, the PML-Q, and its coalition partners have now lost their majority in parliament and Mr Zardari said none of them would be invited into the new governing coalition.

He also said one of the first tasks for the new government, once it was sworn in, would be to ask for UN help in investigating the assassination of his wife, Benazir Bhutto, killed while campaigning in December.

Together, Mr Zardari's and Mr Sharif's parties have more than half of the new parliament's seat. If they can form a grouping with a two-thirds majority, they could call for Mr Musharraf to be impeached.

Mr Sharif has been deeply critical of the president and says he wants "to rid Pakistan of dictatorship forever".

Mr Musharraf has said he will not resign or retire, but instead wishes to work towards stable democratic government in Pakistan.

Mr Musharraf seized power from then-Prime Minister Nawaz Sharif in a military coup in 1999 and was re-elected to the presidency in October in a parliamentary vote boycotted by the opposition as unconstitutional.