Gen Musharraf said the army was the saviour of Pakistan

Gen Musharraf passed a ceremonial baton to Gen Ashfaq Pervez Kayani at the army's headquarters.

In his farewell address, Gen Musharraf said the army was his "life" and he was proud to have been the commander of this "great force".

He had been under huge pressure to quit as army chief and is due to be sworn in as civilian president on Thursday.

Opposition leader Benazir Bhutto welcomed President Musharraf quitting his army post but said her party was in no hurry to accept him as a civilian leader.

US Secretary of State Condoleezza Rice said President Musharraf's stepping down was a good first step but called for a state of emergency to be lifted ahead of January elections.

President Musharraf has led Pakistan's military for nine turbulent years. As a civilian leader he will have to work out a relationship with a new army chief and an elected prime minister.

The BBC's M Ilyas Khan in Karachi says President Musharraf has shown great resilience over the years, often bouncing back when seemingly on the ropes.

His legacy as a military leader on the front line of the "war on terror" is a country beset by militancy.

Despite his having preached "enlightened moderation", President Musharraf is a reluctant democrat whose policies have provided political space for religious conservatives to the exclusion of moderates and liberals, our correspondent says.

'Half a century'

Dressed in full military uniform, Gen Musharraf arrived at the ceremony with a baton under his left arm.

On his arrival, he was greeted by Gen Kayani and inspected a guard of honour.

A military band played Pakistan's national anthem and the ceremony began with a recitation from the Koran.

The colourful ceremony was shown live on national television.

"I am bidding farewell to the army after having been in uniform for 46 years," Gen Musharraf said in his address. He became army chief in October 1998.

"This army is my life, my passion. I love this army, and this relationship will continue, although I will not be in uniform," he said.

Gen Musharraf added:

"I am fortunate to have commanded the best army in the world. This army is an integrating force, the saviour of Pakistan.

"Without this army, the entity of Pakistan cannot exist."

'Excellent soldier'

Gen Musharraf expressed full faith in the ability of his successor, Gen Kayani, to lead the force.

People in Pakistan give their rections as Musharraf quits as head of the army

In pictures



"He's an excellent soldier and I can say with full confidence that under his command, the armed forces will achieve great heights," Gen Musharraf said.

He had designated Gen Kayani, a former head of the intelligence services, as his successor in October.

The most serious pressure on the president to give up his uniform had come from the United States, his main international backer.

Washington has grown concerned in recent months at the army's inability to rein in pro-Taleban militants and by Gen Musharraf's growing unpopularity.

HAVE YOUR SAY The issue is not the individual, Pervez Musharraf. The real issue is the stranglehold that Pakistan Army has over every sphere of life.

Nausherwan Lahori, Lahore

Send us your comments

As a civilian leader, President Musharraf will still have considerable powers, including the ability to sack a civilian government.

He imposed emergency rule on 3 November in order, he said, to control an unruly judiciary and deal with the growing threat from Islamist militants.

General elections are to be held on 8 January. President Musharraf's critics in Pakistan and allies in the West say they cannot be free and fair unless the emergency is lifted.