The doctor, Shakil Afridi, who was tried under Pakistan’s opaque tribal justice system, was instead convicted of colluding with a local Islamist warlord, to whom he was accused of donating more than $20,000.

The revelation, detailed in a five-page court order that was first reported in Pakistan’s Dawn newspaper, adds an intriguing twist to a cloudy case that has come to embody the dismal relations between Islamabad and Washington. News of Dr. Afridi’s conviction a week ago set off fury in Washington, and lawmakers there voted to cut $33 million in American aid to Pakistan, $1 million for each year of his sentence; some suggested that American aid to the country should be severed entirely.

The C.I.A. paid Dr. Afridi to run a vaccination program in Abbottabad in March and April 2011, as cover for an intelligence operation to establish that Bin Laden and his family were living in a large three-story house in the town.

Three weeks after the raid by Navy SEALs that killed Bin Laden on May 2, 2011, Dr. Afridi was picked up by Pakistani intelligence, and he has not been seen since. Despite intense news media speculation that Dr. Afridi would face treason charges in a regular court, his case was moved to Khyber Agency in the tribal belt, which operates under the Frontier Crimes Regulations, an arcane, colonial-era legal system.

In a closed-door hearing in early May, the four-man council of tribal elders that heard Dr. Afridi’s case declined to examine the allegations of C.I.A. ties, citing a lack of jurisdiction. Instead the court focused on Dr. Afridi’s links to Mangal Bagh, an Islamist warlord whose fighters are battling the Pakistan Army in Khyber Agency. He was convicted on May 23 and ordered to pay $3,500 in fines in addition to his lengthy prison sentence.

But Pakistani analysts say that despite the harsh sentence, the fact that he was convicted under tribal law could ultimately work in Dr. Afridi’s favor, leaving more room for an early release — or perhaps even an exchange deal with the United States, said Asad Durrani, a former head of the main Pakistani military intelligence agency.

“In a context like this, between Pakistan and the U.S., people tend to be bargained for and exchanged,” Mr. Durrani said.

Citing intelligence reports, the conviction order noted Dr. Afridi’s “love for Mangal Bagh,” saying their association was an “open secret.” The order claimed Mr. Afridi donated $22,222 to his cause, the antigovernment militant group Lashkar-i-Islam, and provided medical assistance to its commanders.

The order accused Dr. Afridi, as a supporter of Lashkar-i-Islam, of embracing an “ideology based on hatred” that sought to overthrow the government. “His demeanor as a public servant proves his disloyalty and feeling of enmity toward the state and government of Pakistan,” it said.

In interviews, Dr. Afridi’s friends and relatives paint a different picture of that relationship. They say that Lashkar-i-Islam fighters kidnapped Dr. Afridi in 2008, after complaints about his surgical work, and held him hostage until he paid a large fine. “There was a complaint that Afridi was conducting false operations on patients in order to earn extra money,” said Dr. Abdul Qadoos, a former surgeon general in Khyber Agency.

According to various accounts, the militants held Dr. Afridi for one week and released him on payment of a sum between $6,600 and $16,600. Mr. Bagh then expelled Dr. Afridi from Bara, his hometown.

“Some doctors were against him,” said an older relative of Dr. Afridi’s, speaking on the condition of anonymity. “They created a plot and went to Mangal Bagh.”

It could be several years before the United States and Pakistan, whose relations are at a historic low, are in a position to negotiate for Dr. Afridi.

In the meantime his safety is at issue. The government of Khyber-Pakhtunkhwa Province has asked the federal government to transfer Dr. Afridi out of Peshawar Jail, where he is being held, over fears that he could be killed. “There is a serious threat to his life inside the prison due to the presence of a large number of militants incarcerated in the overcrowded Peshawar Jail,” noted a letter sent this week to the Interior Ministry, and seen by The New York Times.

Dr. Afridi should be transferred to another province, the letter urged, because every facility in Khyber-Pakhtunkhwa also holds militants. “The matter may be given top priority,” it said.

A version of this article appears in print on May 31, 2012, on page A12 of the New York edition with the headline: New Details Emerge on Conviction of Pakistani Who Aided Bin Laden Search. Order Reprints|Today's Paper|Subscribe