Nuclear-armed Pakistan's beleaguered President Pervez Musharraf announced his resignation on Monday in the face of an impending impeachment motion by the ruling coalition government.
The former army chief and firm U.S. ally has seen his popularity slide over the past 18 months and has been isolated since his allies lost a February election.
Prolonged jockeying and uncertainty over Musharraf's position had hurt Pakistan's financial markets and raised concern in Washington and among other allies it was distracting from efforts to tackle militants.
In a one-hour long televised address, Musharraf defended his nearly nine-year rule and rejected accusations against him, but said he was leaving office.
"After consultations with legal advisers and close political supporters and on their advice, I'm taking the decision of resigning," a sombre Musharraf said.
"My resignation will go to the speaker of the National Assembly today."
Musharraf seized power in a 1999 coup but has been isolated since his allies lost a February election.
The new coalition government, led by the party of assassinated former prime minister Benazir Bhutto, said early this month that it planned to impeach Musharraf.
The powerful army, which has ruled for more than half the country's 61-year history, has publicly kept out of the controversy over its old boss.
No unrest was expected as a result of the increasingly unpopular leader's resignation.
Investors in Pakistan's financial markets, while appreciating Musharraf's investor-friendly rule which, until this year, saw strong growth and surging stocks, welcomed his resignation as heralding an end to political uncertainty.
Pakistani stocks rose 4 percent on the resignation announcement.
The ruling coalition had prepared impeachment charges against Musharraf ocusing on violation of the constitution and misconduct.
Musharraf rejected the accusations but said the country would lose if he were impeached, no matter what the outcome.
Officials from Saudi Arabia, as well as the United States and Britain, have been involved in negotiations aimed at ending the confrontation between Musharraf and the government.
Coalition officials said Musharraf was seeking immunity from prosecution but he said in his speech he was asking for nothing.
"I don't want anything from anybody. I have no interest. I leave my future in the hands of the nation and people," he said.
The United States, which has relied on Musharraf for Pakistani cooperation in its campaign against terrorism, had said the question of Musharraf's future was for Pakistanis to decide.
U.S. Secretary of State Condoleezza Rice said on Sunday that Musharraf has been a "good ally", but she declined to say whether he would receive U.S. asylum if he stepped down.
"This is an issue that is not on the table," Rice said in an interview with Fox News.