Image copyright AFP Image caption Dr Afridi denies all the charges and says he never got a fair trial

A Pakistani doctor who helped the US find al-Qaeda leader Osama Bin Laden is appealing against his jail sentence.

It's the first time Shakil Afridi's case has been heard in open court. The judge adjourned the case until 22 October at the request of prosecutors.

Dr Afridi's role was a huge embarrassment for Pakistan. He argues he was denied a fair trial.

He was never formally charged for his role in the 2011 operation to hunt down and kill the world's most-wanted man.

Dr Afridi's imprisonment caused outrage and saw the US cut federal aid to Pakistan by $33m (£27m) - $1m for every year of his jail sentence. in the Peshawar High Court

US President Donald Trump promised in his 2016 election campaign that he would get Dr Afridi released in "two minutes" if elected - but that never happened.

While the doctor is considered a hero in the US, in Pakistan he is seen by many as a traitor who brought humiliation to the country - US Navy Seals had been able to fly in, kill the 9/11 attacks mastermind and get away with his body without even being challenged, far less stopped.

Image copyright Reuters Image caption Osama Bin Laden evaded capture for nearly a decade after the 9/11 attacks on the US

And it raised uncomfortable questions about whether Pakistan's military, which runs its security policy, was aware Bin Laden was in the country.

Pakistan remains an uneasy partner to this day in the US-led fight against militant Islam.

Who is Shakil Afridi?

Dr Afridi was the top medic in Khyber tribal district and as head of health services had overseen a number of US-funded vaccination programmes.

As a government employee, he set up a similar hepatitis B vaccination programme, including in the garrison town of Abbottabad, where it turned out Bin Laden was living right under the noses of the military.

The US intelligence plan was to obtain a blood sample from one of the children living in the Abbottabad compound, so that DNA tests could determine whether or not they were relatives of Bin Laden.

It's thought that one of Dr Afridi's staff visited the compound and collected blood - but it's not known whether this proved central to the Americans' success in locating their target.

Dr Afridi was taken into custody on 23 May 2011, 20 days after Bin Laden was killed. He is thought to have been in his late forties at the time.

Image copyright Reuters Image caption Bin Laden's compound in 2012, before it was completely demolished

Little is known about his personal life, other than that he came from a humble background and graduated from Khyber Medical College in 1990. His family have been living in hiding since his arrest, fearing militant attacks.

His wife is an educationalist from Abbottabad who was principal of a government school before they went into hiding. The couple have three children - two boys and a girl, at least two of them now adults.

In January 2012, US officials publicly admitted that Dr Afridi had worked for US intelligence.

But it's far from clear how much he knew about his role for the CIA. He said nothing to this effect during his deposition at the Abbottabad Commission into the killing.

Dr Afridi did not know who the target of the operation was when the CIA recruited him, according to a Pakistani investigation.

What was he convicted of?

Although initially accused of treason, Dr Afridi was ultimately jailed in May 2012, having been found guilty of funding Lashkar-e-Islam, a banned militant group that is now defunct.

He was sentenced to 33 years in prison for alleged links to the group by a tribal court, although this was later reduced to 23 years on appeal.

Dr Afridi was also accused of offering emergency medical aid to its fighters and allowing the group to hold meetings in the government hospital he headed.

His family have vehemently denied these charges and his lawyers say the only money he ever paid the group was a ransom of 1m Pakistani rupees (£5,200; $6,375) to secure his release after they kidnapped him in 2008.

From his jail cell in 2012 he reportedly told Fox News that he had been kidnapped and tortured by Pakistani intelligence.

A year later he managed to smuggle a hand-written letter to his lawyers, saying he'd been denied justice.

So, why wasn't he charged with helping the US?

That's not very clear, but the Bin Laden affair was a huge blow for Pakistan.

Although officials were furious with what they viewed as a violation of sovereignty, the intelligence services had to publicly admit they had no idea that the founder and leader of al-Qaeda had been living there in secret, in a three-storey building behind high walls, for several years.

Image copyright Reuters Image caption Soldiers cleared debris from Bin Laden's compound after the US raid in May 2011

The White House's then-counter-terrorism chief, John Brennan, said at the time that it was "inconceivable that Bin Laden did not have a support system" in Pakistan, an accusation rejected by Islamabad.

But to charge Dr Afridi for his role in the US operation would have meant even more bad publicity.

Why is his case being heard in the courts only now?

So far, the legal process has taken place under British-era Frontier Crimes Regulations, which governed the semi-autonomous Federally Administered Tribal Areas (Fata) along the border with Afghanistan until last year.

Tribal courts were presided over by administrative officials, aided by a council of largely pliable tribal elders, and were not bound to follow due process.

Media playback is unsupported on your device Media caption John Simpson on how the world's most wanted man evaded capture for so long

That was seen as a convenient way of dealing with Dr Afridi, largely out of public sight.

But the merger of the tribal areas with adjoining Khyber Pakhtunkhwa province last year means cases have been moved to regular Pakistani courts.

At the next hearing he could have his sentence cut or it could be increased, as prosecutors will argue.

Since he was moved last year from a Peshawar jail to one in Punjab, there's even been talk that he could be released, possibly in a prisoner swap with Aafia Siddiqui, an alleged al-Qaeda operative currently jailed in the US.