A Pakistani administrator has overturned a judgment sentencing a doctor who helped CIA agents hunting the al-Qaida leader Osama bin Laden to 33 years in prison.

Lawyers for Shakil Afridi, who was convicted of treason in May last year, played down his chances of release, but experts said the decision could be related to a recent improvement in difficult relations between the US and Pakistan. John Kerry, the US secretary of state, raised the issue of Afridi's imprisonment when visiting Islamabad in July.

Michael Kugelman, south Asia expert at the Woodrow Wilson Centre in Washington DC, said: "The US considers this a priority issue. It is a very dysfunctional relationship but has perhaps stabilised to the point where Pakistan is ready to act on a request like this."

Afridi, a former public health officer who reportedly did not know exactly whom the CIA was trying to target when he agreed to work for them, was arrested following the night-time raid on Bin Laden's compound on 2 May 2011.

As first revealed by the Guardian, in the weeks running up to the assault by US navy seals Afridi ran a bogus hepatitis B vaccination campaign for the CIA, designed to collect blood samples in the hope of finding people who matched the Bin Laden family DNA. A match would have helped to definitively identify the extremist leader.

Afridi, 49, was not charged over that alleged offence but for his links with Lashkar-e-Islam, an Islamic militant group active in Khyber agency. He was found guilty of conspiring against the state.

Sahibzada Mohammad Anees, who oversees the implementation of local laws in Pakistan's semi-autonomous tribal agencies, ruled that the official who heard the case exceeded his authority when handing down the sentence last year.

That judgment was passed in consultation with tribal elders in Khyber agency, which lies between the frontier city of Peshawar and the border with Afghanistan. Anees ordered a new trial.

Afridi's sentence angered the US, which withheld £22m in aid for Pakistan in retaliation. The then US defence secretary, Leon Panetta, publicly stated that Afridi "was not in any way doing anything that would have undermined Pakistan". However, it was welcomed by Pakistani security agencies who said the physician had got what he deserved.

There have been signs that Pakistan's civilian bureaucracy and courts are increasingly prepared to challenge the country's powerful security establishment.

A court in Peshawar recently ordered authorities to pay compensation to the mother of a man who was abducted and killed, reportedly by Pakistani security agencies.

In July an unpublished report by a committee overseen by a former top judge seeking to answer questions as to how Bin Laden apparently remained undetected in Pakistan for nearly a decade was leaked to the media.

It was fiercely critical of police and intelligence agencies, calling for a wholesale change in attitudes and working practices.

However, more than two years after the killing of Bin Laden, Afridi is the only person to have been arrested in connection with the event.

The raid, conducted by US special forces transported from Afghanistan in stealth helicopters that evaded Pakistan's air defences, was seen as a humiliation for the country's military establishment. It severely undermined relations between the US and Pakistan.

Afridi's lawyer, Samiullah Afridi, said he was not hopeful about any retrial. "The [original] decision was announced by an assistant political agent, who is an administrator, and it is going back to him [to decide again].

"We do not have any expectations because whatever happens will be according to what the [security] agencies want. We want that Dr Shakil Afridi should be tried by a lower-level judge, at the very least," he said.

The appeal was heard by a bureaucrat because under the colonial-era laws in place in Pakistan's tribal agencies the decisions of political agents, the officials charged with administering justice in the agencies, cannot be heard in a court of law.

The lawyer Afridi said he had been unable to contact his client and inform him of the ruling.

"His lawyers and his family have not been able to meet him for at least eight to nine months, but perhaps he has seen the news if it has appeared in the media," the lawyer, who is not related to his client, told the Guardian.

The hunt for Bin Laden

The plan to obtain DNA samples from Osama bin Laden's family to confirm his presence in the Pakistani garrison town of Abbottabad was set in motion after US intelligence agencies tracked a courier known to be linked to al-Qaida to a large, non-descript compound with high security where, they learned, a tall man with an extensive family lived.

The agency monitored the compound from satellites and through surveillance from a CIA safehouse nearby, but wanted further confirmation that Bin Laden was present before mounting a risky operation inside another country. DNA from any of the Bin Laden children or grandchildren in the compound could be compared with a sample from the al-Qaida leader's sister, who died in Boston in 2010, to provide evidence that the family was present.

So agents approached Dr Shahid Afridi, the health official in charge of Khyber, part of a tribal area that runs along the Afghan border close to Abbottabad. He agreed to help. The doctor went to Abbottabad in March 2011, claiming to have procured funds to give free vaccinations to locals against hepatitis B. Bypassing local health service officials, he paid generous sums to low-ranking local government health workers to administer vaccines door to door in Bin Laden's neighbourhood.

One consequence of the operation has been to deepen existing suspicions among many in Pakistan that polio vaccines are part of a western plot against Islam. This has been described as a major setback in efforts to tackle the disease.