Pakistani President Pervez Musharraf announced Monday that he will resign, just days ahead of impeachment in parliament over attempts by the U.S.-backed leader to impose authoritarian rule on his turbulent nation.
An emotional Musharraf said he wanted to spare Pakistan from a dangerous power struggle.
"I hope the nation and the people will forgive my mistakes," Musharraf said in a televised address largely devoted to defending his record.
Musharraf dominated Pakistan for years after seizing power in a 1999 military coup, making the country a key strategic ally of the U.S. by supporting the war on terror. But his popularity at home sank and his influence has faded steadily over the past year. He quit the pivotal post of army chief in November and his resignation was widely forecast.
Television footage showed groups of people celebrating in the streets in several towns across Pakistan, some of them firing automatic weapons into the sky.
• TIMELINE: Key Dates in Pervez Musharraf's Rule in Pakistan
Washington and European capitals will hope his removal will let the civilian government focus on terrorism and the country's economic woes, though Musharraf's exit also could trigger a struggle to replace him.
Pakistan's stock market and currency both rose strongly on hopes that the country was bound for political stability.
In his hour-long address, Musharraf said he would turn in his resignation to the National Assembly speaker Monday. It was not immediately clear whether it would take effect the same day. Mohammedmian Soomro, the chairman of the upper house of parliament, was poised to take over in the interim.
It remains an open question whom parliament will elect to succeed Musharraf, partly because the ruling coalition has vowed to strip the presidency of much of its power.
There is 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.
It was also unclear whether Musharraf would stay in Pakistan or go into exile.
After inspecting a guard on honor outside his hulking white marble palace in the capital, a pokerfaced Musharraf stepped into a black limousine and left the building — perhaps for the last time.
Chaudhry Shujaat Hussain, head of the main pro-Musharraf party, said Musharraf would live in Islamabad, where he owns a farmhouse on the outskirts.
Foreign Minister Shah Mahmood Qureshi said leaders of the ruling coalition would discuss later Monday whether to prosecute Musharraf in court on the impeachment charges.
His political foes put those issues on the back-burner briefly and got on with celebrating.
"It is a victory of democratic forces," Information Minister Sherry Rehman said. "Today, the shadow of dictatorship that has prevailed for long over this country, that chapter has been closed."
In the northern city of Peshawar, a crowd of people danced to drum beats and embraced at an intersection.
"It is very pleasing to know that Musharraf is no more," said Mohammed Saeed, a shopkeeper among the crowd.
"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 economic problems that include runaway inflation.
Many Pakistanis blame the rising militant violence in their country on Musharraf's use of the army against militants nested in the northwest. His reputation suffered fatal blows in 2007 when he ousted dozens of judges and imposed emergency rule. His rivals won February parliamentary elections and have since sought his ouster.
Musharraf, who has been largely sidelined since his rivals came to power, finally yielded after the coalition finalized impeachment charges against him and threatened to send a motion to Parliament later this week.
The charges were expected to include violating the constitution and gross misconduct, likely in connection with the ouster of the judges and the declaration of emergency rule.
A defiant Musharraf, seated in an office between two national flags, listed the many problems facing Pakistan, including its sinking economy and a chronic power shortage. He said his opponents were wrong to blame him for the mounting difficulties and suggested they were going after him to mask their own failings.
"I pray the government stops this downward slide and takes the country out of this crisis," he said.
Allies and rivals of the president said talks had suggested that Musharraf might quit in return for legal immunity from future prosecution.
Sharif's party insists he should be tried for treason, which carries a maximum punishment of 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," its spokesman Ahsan Iqbal said Monday.
Qureshi would not say whether Musharraf might be granted a "safe exit" — speculation has focused on whether he might go into exile in Saudi Arabia or Turkey.
"That is a decision that has to be taken by the democratic leadership," Qureshi, who is from the main ruling Pakistan People's Party, told Dawn News television.
The ruling parties also came under immediate pressure from protesting lawyers to meet a promise to restore the ousted judges — a matter fraught with political calculations because of Sharif's vociferous championing of their cause.
Law Minister Farooq Naek said both the means and the timing of their restoration remained open.
The international response made clear how world leaders had moved on from their reliance on Musharraf to keep his nuclear-armed nation on its current, moderate track.
Nations including British and Germany, who both have troops in Afghanistan and worry about al-Qaida plotting attacks on their soil from havens in Pakistan, urged the civilian government to bolster their security policies as well as Pakistani democracy.
However, the Afghan government, which accuses Pakistan of secretly aiding the Taliban, could not resist a parting shot.
Musharraf "was not someone good for Afghanistan," Interior Ministry spokesman Zemeri Bashary said, accusing him of being an ally of the United States in words only.
A U.S. Embassy spokesman declined to comment after Musharraf's speech, referring calls to Washington.
Secretary of State Condoleezza Rice said Sunday that while Musharraf had been a "good ally," Washington was supportive of the new government and Musharraf's future was an internal issue.
"Pakistan and the United States have a joint interest in fighting terror," Rice said on Fox News television. "That's what we're concentrating on, that and helping Pakistan to sustain its economy, to build its schools, its health. We have a broad Pakistan policy."