The president's move resolves a row with an opposition Islamic alliance that had virtually paralysed parliament on the issue.
Musharraf called his decision "difficult".
"I realise that it's time. I have decided that I will give up my uniform by December 2004 and will step down as Chief of Army Staff," he said on state television.
Speaking in Urdu and wearing military dress, Musharraf added: "These are all historic decisions. Nobody has won or lost because of these decisions. Democracy has won and the victory is Pakistan's."
Musharraf made the decision as part of a deal with the opposition Muttahida Majlis-e-Amal (MMA) - an alliance of six Islamic opposition parties - which have promised to abstain in a vote of confidence in the government expected early next year.
The Commonwealth had also demanded such a move for suspended Pakistan to be re-admitted.
It comes after months of wrangling with the MMA religious bloc over constitutional changes giving the president sweeping powers.
"Democracy has won and the victory is Pakistan's"
The package of amendments, called the Legal Framework Order (LFO), gave Musharraf the power to dissolve parliament and sack the prime minister.
The MMA, which counts supporters of Afghanistan's ousted Taliban among its leaders, has virtually paralysed parliamentary proceedings with stormy protests complementing that with popular rallies against the president.
"It (the deal) will improve Pakistan's image abroad and give the world the impression that Pakistan is moving towards democracy," said Fazal-ur-Rehman, a prominent MMA leader.
Under the agreement with the MMA, Musharraf will require the Supreme Court's approval before sacking the government.
The general called elections in October 2002 to end military rule after his bloodless coup in 1999, but he has remained in ultimate control of the country while the government has run its day-to-day affairs.
In a referendum last year, which opponents said was rigged, Musharraf handed himself five more years in power.
Pakistan has been ruled by military dictators for around half of its 56-year history.