Speaking at a ceremony at the military headquarters near the capital, Islamabad, Musharraf said: "I am saying 'farewell' to the armed forces, which have been like a family to me."
Musharraf handed over the post to a hand-picked successor, his close ally General Ashfaq Kayani, a U.S.-educated former intelligence chief.
The president has ruled the country since seizing power via a military coup in 1999, retaining the post of military commander. In 2004, he pledged to relinquish military command, but had until now failed to fulfill the promise, citing instability in the country and a persisting threat from Islamist radical elements. The move ends his 46-year military career.
Musharraf was reelected by parliament in October, but the Supreme Court suspended official results over opposition complaints that a military official could not be an elected head of state under the Constitution.
The president imposed a state of emergency on November 3, dismissed the chief justice and appointed loyal judges to the court. The reshaped court approved his election last Thursday.
Independent media in Pakistan cited "reliable sources" on Wednesday as saying emergency rule could be dropped after Musharraf takes his oath as president, but did not give a precise date. - RIA Novosti