An emotional Musharraf said he wanted to spare the nation from a perilous impeachment battle and that he was satisfied that all he had done "was for the people and for the country."
"I hope the nation and the people will forgive my mistakes," Musharraf said in a televised address, much of which was devoted to defending his record and refuting criticisms.
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 over the years.
In addition, Musharraf's loss of power within the military may have also doomed his presidency.
"The military has been central to this major shift in Pakistan," said one senior western diplomat, who spoke to CBS News on condition of anonymity Monday after Musharraf's announcement.
Last week, senior army officers told CBS News, they had conveyed to the former president that the powerful army would not actively support him.
The message from the army made a fundamental difference to Musharraf in a country where the armed forces have ruled Pakistan for more than half its 61 year existence as an independent state, reports CBS News reporter Farhan Bokhari.
The Pakistani military is considered to be the only main institution which can play a role in curbing the flow of Taliban' and al Qaeda militants from Pakistan's border region in to Afghan territory where troops from NATO and the US are deployed to fight a raging Islamist insurgency, Bokhari reports.
With Musharraf's utility fading, the West has appeared less concerned with his fate than about how the clamor was affecting the halting efforts of the new civilian government against terrorism and the gathering economic woes.
Many Pakistanis blame the rising militant violence in their country on Musharraf's alliance with the U.S. His reputation suffered 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, announcing impeachment plans earlier this month.
A U.S. Embassy spokesman declined to comment after Musharraf's speech, referring calls to Washington. Secretary of State Condoleezza Rice said Sunday the Pakistani president's future was an internal issue.
While Musharraf was a "good ally" who "kept his word" on ending military rule when he stepped down as army chief last year, whether he should resign "is a matter for Pakistan to determine," she said.
People celebrated in the streets of some Pakistani cities at the news of the resignation. resignation. In Rawalpindi, supporters of the Pakistan People's Party shot into the air with rifles. Lawyers gathered and waved flags outside the Parliament building in Islamabad.
Musharraf said he will turn in his resignation to the National Assembly speaker on Monday but it was not immediately clear whether it would become effective the same day. The chairman of Pakistan's Senate, Mohammedmian Soomro, will take over as acting president when Musharraf steps down, Law Minister Farooq Naek said.
It also was not clear whether Musharraf, a stalwart U.S. ally, would stay in Pakistan.
Foreign Minister Shah Mahmood Qureshi said leaders of the ruling coalition would discuss later Monday whether to prosecute Musharraf in court on charges that that were being planned for the impeachment process.
Musharraf's political foes celebrated.
"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."
Musharraf, who has been largely sidelined since his rivals came to power, had resisted the mounting calls to quit, even 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.
In announcing he would quit after all, Musharraf mentioned the many problems facing Pakistan, including its sinking economy. He said his opponents were wrong to blame him for the mounting difficulties. "I pray the government stops this down-sliding and take the country out of this crisis," he said.
Allies and rivals of the president said talks had been under way to get him to step down by possibly granting him legal immunity from future prosecution. The second biggest party in the government has said he should be tried for treason, which carries a maximum punishment of death.
Who will ultimately succeed Musharraf is an open question. There has been speculation that both Nawaz Sharif and Asif Ali Zardari, the leaders of the two main parties are interested in the role.
But the ruling coalition has sought to strip the presidency of many of its powers. Sharif spokesman Saiqul Farooq recently dismissed the idea that his boss wants the job because the presidency would likely be reduced to a ceremonial position.
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 - or dragged through the courts.
"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 leaders would assess the speech and the political situation, he said.