By M Ilyas Khan
BBC News, Karachi
Mr Sharif's party has done surprisingly well in the elections
The results in so far from Pakistan's elections suggest that all of President Pervez Musharraf's plans are being thrown into disarray.
It seems like Mr Musharraf's chief political ally, the Pakistan Muslim League - Quaid-e-Azam (PML-Q), has been routed.
The president must also be worrying about the rather unexpected rise of former Prime Minister Nawaz Sharif's PML-N party, which he ousted from power in a military coup in 1999.
The PML-N and the Pakistan Peoples' Party (PPP) led by Benazir Bhutto until her assassination in December are the big winners so far.
The PML-Q has fared exceptionally poorly, coming well behind the two opposition parties.
The PML-N and PPP have been talking to each other in the run-up to the elections, and could possibly join forces in a strong coalition government.
This would not augur well for Mr Musharraf.
The results are bound to worry President Musharraf
The PML-N has been voicing a hawkish agenda against Mr Musharraf's decisions to sack the country's top judiciary and impose emergency rule last November.
There is also a possibility of such a coalition mobilising enough parliamentary support to impeach Mr Musharraf, or strip him of his powers to sack the government.
His best bet would be to try to prevent the two parties from joining forces in the future government.
Given the choice, his preference would be to team up with the PPP, which has appeared to be less harshly critical of his policies, to lead a coalition excluding the PML-N.
That would mean providing the PPP with a coalition partner having enough parliamentary strength to form a government.
The problem is, that according to the results so far, the PML-Q does not seem to be shaping up for such a role.
Mr Musharraf's other ally, the Muttahida Quami Movement (MQM), has predictably swept the election in the country's largest city, Karachi.
But the party is a regional group with limited support and cannot replace the wider clout wielded by PML-Q when it was in power.
Many analysts tend to interpret the results as a "referendum" against Mr Musharraf's policies.
MQM has swept the election in Karachi
Not only has the PML-Q been routed, but the religious grouping, the MMA, has also been almost swept clean from its stronghold in the country's western frontier region.
The North West Frontier Province (NWFP), where the MMA won across-the-board in 2002, appears to have gone "back to its roots", as one analyst puts it.
A secular nationalist group, the ANP, appears set to emerge as the largest party in NWFP, closely followed by the PPP.
The PPP has also registered a considerable presence in the south-western Balochistan province, where the mandate appears to be largely splintered, indicating a weak coalition government.
The province has been marred by a low-intensity armed nationalist insurgency for several years, and most local nationalist groups have boycotted the elections.
In Sindh, the PPP is sweeping the rural areas, which account for more than 60% of the total population of the province.
In Punjab, the PPP is emerging as a strong runner-up behind PML-N.
Although there are some credible allegations of election-day rigging, mostly in Sindh, analysts believe the election exercise has been largely fair.
They say this was made possible due to close scrutiny by the international community, the local media, and the government's fears that rigging may lead to popular uprising.
But a low voter turnout due to fear of violence and, in some cases intimidation, has prevented the results from being even worse as far as Mr Musharraf is concerned.
A higher turnout would have resulted in a near clean sweep against the president and his policies.
Meanwhile, a month-long delay in the elections is seen by analysts as having dented the support of the PPP which, they say, was set to attract a larger vote and a higher turnout had the elections taken place as scheduled on 8 January.
The government postponed the elections when Ms Bhutto was assassinated on 27 December.
All the opposition parties, including the PPP, had resisted the postponement.