A court in Pakistan has ruled that the formation of a special court that handed former Pakistani military ruler Pervez Musharraf a death sentence was unconstitutional, casting into doubt the legitimacy of last month's verdict.

Musharraf was sentenced to death in absentia by a special court in December on treason charges stemming from his imposition of a state of emergency in 2007.

More:

At the time, Musharraf - who is in self-imposed exile in Dubai - denounced the ruling it as a "vendetta" and the military expressed its disappointment.

It was not immediately clear if Monday's ruling by the High Court in Lahore would automatically nullify the death sentence, but Musharraf's side was confident.

"The Lahore High Court has nullified the decision about Pervez Musharraf," Azhar Siddique, Musharraf's lawyer, told Reuters news agency on Monday.

The original ruling marked the first time a former leader of the armed forces had faced such a sentence for treason in Pakistan, where the military maintains strong influence and senior officers are often considered immune from prosecution.

US key ally

The treason trial - which began in 2013 and is just one of several involving Musharraf - centred on his decision to suspend the constitution and impose emergency rule in 2007.

Musharraf first took power after overthrowing Prime Minister Nawaz Sharif in a bloodless coup in 1999.

His rule faced no serious challenges until he tried to sack the Supreme Court chief justice in March 2007, sparking nationwide protests and months of turmoil that led to the imposition of emergency rule.

After the December 2007 assassination of former Prime Minister Benazir Bhutto, the national mood plunged further and Musharraf was left increasingly isolated by the crushing losses suffered by his allies in February 2008 elections.

He finally resigned in August 2008 in the face of impeachment proceedings by the new governing coalition and went into exile.

Musharraf returned to Pakistan in 2013 in an attempt to contest elections, but was barred from taking part in the polls and from leaving the country as a barrage of legal cases mounted.

The travel ban against him was finally lifted in 2016, and he travelled to Dubai for medical treatment, where he has been ever since.

The treason case against him was first launched by his old foe Sharif in 2013. It went on for years with repeated delays until last year's surprise announcement.