Almost all the leading figures in the Pakistan Muslim League-Q, the party that has governed for the last five years under Mr. Musharraf, lost their seats, including the leader of the party, the former speaker of Parliament and six ministers.
Official results are expected Tuesday, but early returns indicated that the vote would usher in a prime minister from one of the opposition parties, and opened the prospect of a Parliament that would move to undo many of Mr. Musharraf’s policies and that may even try to remove him.
The early edge went to the opposition Pakistan Peoples Party, which seemed to benefit from a strong wave of sympathy in reaction to the assassination of its leader, Benazir Bhutto, on Dec. 27, and may be in a position to form the next government.
The results were interpreted here as a repudiation of Mr. Musharraf as well as the Bush administration, which has staunchly backed Mr. Musharraf for more than six years as its best bet in the campaign against the Islamic militants in Pakistan. American officials will have little choice now but to seek alternative allies from among the new political forces emerging from the vote.
Politicians and party workers from Mr. Musharraf’s party said the vote was a protest against government policies and the rise in terrorism here, in particular against Mr. Musharraf’s heavy-handed way of dealing with militancy and his use of the army against tribesmen in the border areas, and against militants in a siege at the Red Mosque here in the capital last summer that left more than 100 people dead.
Others said Mr. Musharraf’s dismissal last year of the Supreme Court chief justice, Iftikhar Muhammad Chaudhry, who remains under house arrest, was deeply unpopular with the voters.
Mr. Musharraf, who stepped down as army chief last November after being re-elected to another five-year term as president, has seen his standing plummet as the country has faced a determined insurgency by the Taliban and Al Qaeda, and a deteriorating economy.
By association, his party suffered badly. The two main opposition parties — the Pakistan Peoples Party and the Pakistan Muslim League-N of Nawaz Sharif, a former prime minister — surged into the gap.
By early Monday night, crowds of Sharif supporters had already begun celebrating as they paraded through the streets of Rawalpindi, the garrison town just outside the capital, Islamabad. Riding on motorbikes and clinging to the backs of minivans, they played music and waved the green flags of Mr. Sharif’s party decorated with the party symbol, a tiger.
From unofficial results the private news channel, Aaj Television, forecast that the Pakistan Peoples Party would win 110 seats in the 272-seat National Assembly, with Mr. Sharif’s party taking 100 seats.
Mr. Musharraf’s party, the Pakistan Muslim League-Q, was crushed, holding on to just 20 to 30 seats. Early results released by the state news agency, The Associated Press of Pakistan, also showed the Pakistan Peoples Party to be leading in the number of seats won.
The Election Commission of Pakistan declared the elections free and fair and said the polling passed relatively peacefully, despite some irregularities and scattered violence. Ten people were killed and 70 injured around the country, including one candidate who was shot in Lahore on the night before the vote, Pakistani news channels reported.
Fearful of violence and deterred by confusion at polling stations, voters did not turn out in large numbers. Yet fears from opposition parties that the government would try to rig the elections did not materialize, as the early losses showed.
Official results were not expected until Tuesday morning, but all the parties were already coming to terms with the anti-Musharraf trend in the voting.
At the headquarters of Sheik Rashid Ahmed, the minister of railways and a close friend of the president, his supporters sat gloomily in chairs under an awning, listening to the cheers of their opponents. “Q is finished,” said Tahir Khan, 21, one of the party workers, referring to the pro-Musharraf party.
The party workers said Mr. Ahmed, who was among the ministers who lost their seats, was popular but had suffered from the overwhelming protest vote against Mr. Musharraf and his governing faction.
The results opened a host of new challenges for the Bush administration, which has been criticized in Congress and by Pakistan analysts for relying too heavily on Mr. Musharraf. Even as Mr. Musharraf’s standing plummeted and the insurgency gained strength, senior Bush administration officials praised Mr. Musharraf as a valued partner in the effort against terrorism.