ISLAMABAD, Pakistan — Pervez Musharraf resigned Monday as the president of Pakistan, avoiding a power struggle with rivals vowing to impeach him that would have deepened the country's political crisis.
His exit, announced in an emotional televised address, leaves the politicians who pushed out the stalwart U.S. ally to face the Islamic militants and economic problems gnawing at this nuclear-armed nation.
"There is a huge challenge ahead," said Shafqat Mahmood, a former government minister and prominent political analyst. "Now this whole Musharraf excuse is behind us. Now people are going to be focusing on their performance."
Musharraf's departure after nearly nine divisive years in power was widely expected after months of rising pressure for him to leave, culminating in the threat to bring impeachment charges to Parliament this week.
A diminished figure since he resigned as army chief in November and found himself cut out of policymaking by the civilian government, the 65-year-old former general left the presidency amid a palpable lack of overt support from either of his main props _ the army and Washington.
Underlining how the West has already moved on, Secretary of State Condoleezza Rice offered "deep gratitude" for Musharraf's decision to join the U.S.-led fight against extremists following the Sept. 11 attacks, saying he "served as a good ally of the United States."
But she was careful to signal strong support for the civilian government that pushed him aside.
"We believe that respect for the democratic and constitutional processes in that country is fundamental to Pakistan's future and its fight against terrorism," Rice said.
Still, Musharraf's demise throws up a string of critical questions, including whether the ruling coalition will hold together without its common foe and whether the main parties will maintain Musharraf's close alliance with the U.S.
Musharraf's departure is unlikely to have a significant impact on how Pakistan's nuclear weapons are controlled, however. Experts say a 10-member committee, and not just the president, makes decisions on how to use them.
In an hour-long address devoted largely to defending his record, Musharraf listed the many problems now facing Pakistan, including its sinking economy and a chronic power shortage, and suggested his opponents were targeting him to mask their own failings.
"I am going with the satisfaction that whatever I have done was for the people and for the country ... I hope the nation and the people will forgive my mistakes," he said.
In cities across Pakistan, crowds gathered to celebrate, some firing automatic weapons into the sky.
"It is very pleasing to know that Musharraf is no more," said Mohammed Saeed, a shopkeeper in a crowd of people dancing to drum beats and hugging each other at an intersection in the northwestern city of Peshawar.
"He even tried to deceive the nation in his last address. He was boasting about economic progress when life for people like us has become a hell," he said, because of problems that include runaway inflation.
But many revelers were already thinking to the future.
"The government had been blaming Musharraf for inflation, power cuts and the weak economy, and since now he has resigned, we hope that the government will take steps to make our life better," said Asma Bibi, a housewife in the central city of Multan.
The government said Musharraf's retreat was a victory for democracy over dictatorship _ Pakistan has spent about half its 61-year history under military rule.
"His resignation clears the way for our government to get on with ... providing to the people of Pakistan basic social services, economic opportunities, political security and law and order," Information Minister Sherry Rehman said.
Pakistan's stock market and currency both rose strongly on hopes the country was bound for political stability.
However, analysts say the coalition must quickly clear two more political hurdles in order to survive: elect a new president and resolve the country's judicial crisis.
According to the constitution, parliament must elect a new president within 30 days. There has been speculation that both Asif Ali Zardari and Nawaz Sharif, the leaders of the two main parties, are interested in the role. However, neither has openly said so and both have vowed to strip the post of much of its power.
Senate speaker Mohammedmian Soomro, the chairman of the upper house of Parliament, will act as interim president, but is viewed as a Musharraf loyalist with no chance of keeping the job.
The coalition also faces huge pressure from public opinion and lawyers who have protested against Musharraf for more than a year to restore the Supreme Court judges ousted when Musharraf imposed emergency rule last year.
Those moves undercut Musharraf's already sinking popularity and helped propel his allies to defeat in February elections.
The coalition that replaced them was founded on a pledge to restore the judges that has remained unfulfilled _ a reluctance many attribute to Zardari's concern the judges are too close to Sharif, who loudly championed their cause.
Law Minister Farooq Naek said Monday the "modalities" of how and when the judges will return were still open.
Talat Masood, a former army general turned political analyst, forecast the coalition would find compromises for both the presidency and the judiciary, partly because neither wants to tackle the country's problems alone.
"It's a huge challenge and they cannot face it individually. It's very important for them to work together and I think they know that," he said.
However, Najam Sethi, editor of the Daily Times newspaper, forecast that wrangling in the coalition _ the two main parties fought bitterly for power in the 1990s, when both were stained by allegations of corruption _ will hamper policymaking.
"America wants some immediate decisions (on fighting terrorism), and I don't think they will be able to concentrate on that," Sethi said. "On the other hand are the people of this country, the business community, and there, too, I don't see any new initiatives."
Another mystery unresolved Monday was Musharraf's own fate.
Musharraf, then the army chief, seized power from Sharif in a 1999 coup. Sharif, who was jailed, sent into exile and only returned to Pakistan last year, has vowed to put Musharraf on trial for treason _ a crime punishable by death.
"The crimes of Musharraf against the nation, against the judiciary, against democracy and against rule of law in the country cannot be forgiven by any party or individual," Sharif's spokesman, Ahsan Iqbal, said Monday.
Supporters and foes had suggested that Musharraf was holding on for guarantees that he would not face criminal prosecution or be forced into exile.
"Musharraf would probably go away for a while," because of threats to his security _ he has survived several assassination attempts _ and to help defuse calls for criminal prosecution, Masood said.
"Whatever one might say, it may be difficult for the politicians to give him the indemnity," even if it has been promised, he said.
Musharraf offered no details of his future plans in his address.
Most of the monologue was a feisty defense of his achievements _ keeping Pakistan out of the U.S. firing line after the 9/11 attacks, easing tension with archrival India and overseeing an economic boom that is only now starting to falter.
But as he turned to his present predicament, his brow grew more furrowed and the pauses between his sentences longer.
Before announcing his resignation to spare the nation from a power struggle that could have dragged the army back in to arbitrate, he complained that his opponents had snubbed his offers of reconciliation.
"There were certain elements who were politicking with the economy and terrorism," he said.
Associated Press writers Asif Shahzad, Munir Ahmad and Zarar Khan in Islamabad, Riaz Khan in Peshawar and Khalid Tanveer in Multan contributed to this report.