Pakistani President Pervez Musharraf's opponents headed for election victory on Tuesday after voters rejected his former ruling party, raising questions about the future of the U.S. ally who has ruled since 1999.
No party is expected to win a majority in the 342-seat National Assembly but the opposition parties of assassinated former prime minister Benazir Bhutto and another former prime minister, Nawaz Sharif, were set to be the biggest.
Whichever is bigger will be best placed to lead a coalition.
As president, former army chief Musharraf did not contest Monday's elections, aimed at completing a transition to civilian rule, but the outcome could seal his fate.
A hostile parliament could try to remove Musharraf, who took power as a general in a 1999 coup and emerged as a crucial U.S. ally in a "war on terror" that most Pakistanis think is Washington's, not theirs.
The election was relatively peaceful after a bloody campaign and opposition fears of rampant rigging by Musharraf's supporters appeared unfounded.
The vote was postponed from Jan. 8 after Bhutto was assassinated in a suicide attack on Dec. 27, which raised concern about the nuclear-armed country's stability.
Bhutto's Pakistan People's Party (PPP) has been expected to reap a sympathy vote and was doing well, partial results showed.
But unofficial Election Commission tallies showed Sharif's party leading in Punjab province where half the members of parliament will be elected.
As results came in showing prominent members of the pro-Musharraf Pakistan Muslim League (PML) losing seats, analysts weighed the implications for a president whose popularity has slumped over the past year.
"It's the moment of truth for the president," said Abbas Nasir, editor of the Dawn newspaper. "There will be thoughts swirling in his mind, whether he can forge a working relationship with two parties whose leadership he kept out of the country."
Bhutto spent eight years in self-exile to avoid corruption charges she denied. Sharif was exiled a year after Musharraf ousted him in 1999. Both returned late last year.
Sharif was barred from the election because of past criminal convictions he says were politically motivated.
According to unofficial results from 180 seats, Sharif's Pakistan Muslim League (Nawaz) had won 58, the PPP 56 and the PML 21. Small parties and independents shared the others. Full unofficial election results are due later on Tuesday.
Despite a mixed record as prime minister, when he clashed with the judiciary, Sharif's defiance of old foe Musharraf and support for the judges he purged appeared to have paid off.
A victory for Sharif, who Musharraf ousted in 1999, would be a disaster for Musharraf. Sharif has repeatedly called for Musharraf's removal and analysts say Musharraf wants a coalition between the PPP and the PML.
Some analysts said the decisive factor in the PML's defeat was Musharraf, who angered many Pakistanis when he imposed six weeks of emergency rule and purged the judiciary, and resentment over inflation, food shortages and power cuts.
PML president Chaudhry Shujaat Hussain, a former prime minister, lost his seat in Punjab to a Bhutto party candidate, television networks said. Several other top PML members, including ministers in the outgoing government, also lost seats.
Groups of opposition supporters celebrated in the streets of Lahore, Rawalpindi and Karachi as results trickled out.
Musharraf said on Monday he would work with whoever won to build democracy in a country that has alternated between civilian and army rule throughout its 60-year history: "Everyone should accept the results, that includes myself," he said.
Fear appeared to have kept many people from the polls, despite 80,000 troops backing up police, although a poll watchdog group said initial estimates suggested turnout of nearly 42 percent, almost matching that in the last election in 2002.
A suicide bomb campaign waged by al Qaeda-inspired militants has added to a mounting sense of insecurity. More than 450 people have been killed in militant-related violence this year, many in the northwest where religious parties fared poorly.
Election-day violence, though bad in places, was not as severe as many had feared. Twenty people were killed, including 15 PPP activists, Bhutto's widower Asif Ali Zardari said.
The poll watchdog group said there had been a few incidents of polling irregularities.
Western allies hope for a stable Pakistan focused on fighting militancy, as do investors in a stock market that rose 40 percent last year but has shed about 3 percent since Bhutto's death.