President Gen. Pervez Musharraf cleared the main hurdle to his bid for another five years in power Friday when Pakistan's Supreme Court squashed legal challenges to the leader's increasingly unpopular and bitterly opposed candidacy.

Musharraf, a close U.S. ally, appeared set for victory in an Oct. 6 presidential ballot by national and provincial legislatures, where his supporters hold a majority. He has promised to resign as army chief if elected to a new five-year term, restoring civilian rule.

In its 6-3 ruling, the high court dismissed petitions filed by opposition parties and lawyers arguing that Musharraf could not be a candidate while retaining his heavyweight military post.

The ruling triggered jubilation in the government and anger among the opposition, which vowed to keep fighting to stop Musharraf. Some in the opposition threatened to have their lawmakers resign from Parliament in an attempt to rob the presidential vote of legitimacy.

But analysts said it was unlikely his candidacy could be derailed, noting that the country's squabbling opposition parties are weak and unable to work together.

Many in the opposition had been looking to the Supreme Court as the best hope for blocking Musharraf's plan to extend his eight-year rule, since its judges had issued a series of rulings earlier in the year that limited his authority.

Presiding Judge Rana Bhagwandas gave only a cursory explanation for Friday's ruling, which drew howls of protest from black-suited lawyers crowding the cavernous courtroom. The six judges in the majority ruled the issues raised by the petitions did not fall in their jurisdiction.

"These petitions are held to be non-maintainable," Bhagwandas said, prompting lawyers in the room to chant "Shame, shame!" and "Go, Musharraf, go!"

Outside, dozens of supporters of an Islamist opposition party threw tomatoes and eggs at the court's front gate while chanting slogans against the president. Police kept them separated from about 100 Musharraf supporters.

Musharraf, who seized power in a 1999 coup, has seen his unpopularity rise since he tried to oust the Supreme Court's chief judge in March — a move that was overturned by the court. He is also struggling to contain increasingly violent Islamic militants and faces growing sentiment among Pakistanis that his alliance with Washington is fanning extremism.

But Musharraf sought to retake the political initiative in recent weeks.

He pledged to resign his military post if re-elected president and restore civilian rule to a country that has lurched between unstable elected governments and military regimes during its 60-year history.

At the same time, he clamped down on his most vociferous opponents. Nawaz Sharif, the prime minister deposed in 1999, was sent back into exile when he tried to return this month. And this week, authorities rounded up hundreds of opposition activists to prevent protests, although the Supreme Court on Thursday ordered them freed.

Musharraf's government called Friday's ruling a milestone on Pakistan's path back to democracy. "Justice triumphs," presidential spokesman Rashid Quereshi said.

While the ruling will further polarize Pakistan's politics, there is no sign that the bickering opposition parties can mobilize widespread resentment at Musharraf and the army.

Talat Masood, a prominent political analyst, said Musharraf's insistence on securing re-election before quitting the army showed that real power still resides with the military.

"It looks as though the country is very much divided at the moment, and they (the military) have been successful in doing that and are able to hold on to power," Masood said.

Ayaz Amir, a columnist for the Dawn newspaper, predicted the ruling would deflate opposition efforts and said Musharraf now appeared unstoppable.

"The disappointment across the country will be huge. There will be a more realistic assessment of what is possible now and what is going to happen," Amir said. "They will be in celebratory mood in Army House."

On Saturday, the Election Commission is due to assess the eligibility of the 43 presidential candidates. The main challenger to Musharraf is likely to be retired Justice Wajihuddin Ahmed, who was nominated by lawyers.

Farid Piracha, a lawmaker for the Jamaat-e-Islami party, which filed one of the petitions, rejected the Supreme Court's decision.

"The judges have not fulfilled their constitutional obligation," Piracha said. "Now our fight against dictatorship will be on the streets ... This decision does not reflect the sentiments of the people, and it will not be accepted."

Javed Hashmi, acting leader of Sharif's party, said their lawmakers would resign from Parliament, an opposition strategy intended to taint the presidential ballot's legitimacy.

Former Prime Minister Benazir Bhutto, who is in self-exile, still hopes to negotiate a power-sharing deal between her moderate Pakistan People's Party and Musharraf's party after parliamentary elections that must be held by January.

Musharraf has so far held out against Bhutto's demand that he yield some of the presidency's sweeping powers, including the right to fire the government.

After Friday's court ruling, Bhutto told Geo TV that her party could join other opposition groups in resigning from the assemblies if Musharraf did not move toward restoration of democracy.

"Musharraf and his team say they want national reconciliation, but there is difference between saying something and implementing it," she said.