A court in Pakistan has charged former military ruler Pervez Musharraf with treason, the first army chief to face such a prosecution.

Mr Musharraf is accused of unlawfully suspending the constitution and instituting emergency rule in 2007.

He pleaded not guilty and has always claimed that the charges against him are politically motivated. He could face the death penalty if convicted.

President from 2001 to 2008, he was one of Pakistan's longest-serving rulers.

At the scene

By Shumaila JafferyBBC Urdu, Islamabad

Pervez Musharraf was surrounded by military commandos when he entered the court room. He tried to put on a brave face, waving to those gathered in the courtroom.

As charges were read out to him, Mr Musharraf stood up, looking grim and pale.

But when he began his address to the court he was firm and confident. He denied all the charges and spoke of his achievements: the economic development during his rule and his services for Pakistan's military. And then he asked how he could possibly be called a traitor.

Security was tight, as expected. There were more than 100 security personnel in the court room and the building was also surrounded by troops.

He went into self-imposed exile in 2008, returning to Pakistan in March 2013.

He had hoped to lead his party into elections, but was disqualified from standing and found himself fighting an array of charges relating to his time in power.

The 70-year-old has been in hospital since the beginning of the year and reports say he is being treated for high blood pressure.

'Loyal to the country'

The court on Monday also rejected Mr Musharraf's application to leave the country to visit his sick mother in Dubai.

He is currently under house arrest and has been placed on an exit control list restricting certain Pakistani nationals from leaving the country.

Judges rejected his application on the grounds that only the government had the authority to remove him from the list.

When the former president entered the court he was heavily guarded, but nevertheless appeared relaxed, even waving to the audience.

The judge read out five charges to Mr Musharraf.

He pleaded "not guilty" to each of them but also addressed the court with a speech about his services to the country and questioned how he could be called a traitor, declaring that he was a patriot.

Cases against Musharraf

Since Pervez Musharraf's return to Pakistan in March 2013, he has faced four criminal cases but was bailed in all of them. He was charged:

In connection with the 2006 killing of a rebel Baloch politician, Akbar Bugti

In connection with the 2007 assassination of former Prime Minister Benazir Bhutto

For putting nearly 60 senior judges under house arrest in November 2007

Although he was not formally charged, he is on bail in connection with the killing of a cleric in the 2007 Red Mosque siege in Islamabad

His most serious challenge is a treason case, which bears five charges including suspending the constitution and imposing emergency rule. He has pleaded not guilty but could face death if convicted.

"I am being called a traitor, I have been chief of army staff for nine years and I have served this army for 45 years. I have fought two wars and it is 'treason'?" the Agence France-Presse news agency quoted him as saying.

"Is this the way to reward someone for being loyal to the country and for loving the country?" the former president asked the court.

Mr Musharraf insists that he acted within the constitution when he declared a state of emergency in the country in 2007 and that he did not act alone when taking that decision.

Mr Musharraf seized power from Mr Sharif in a coup in 1999. He remained president until 2008, when a democratically elected government came into power.

He left the country soon afterwards to live in self-imposed exile in Dubai and London.