In Washington, Obama administration officials expressed anger and frustration at the tribal court’s decision, but indicated that American officials were working quietly behind the scenes to shorten the sentence or have it dismissed.

“The doctor was never asked to spy on Pakistan,” said a senior American official with knowledge of counterterrorism operations against Al Qaeda in Pakistan, who spoke on the condition of anonymity in order to talk candidly about the sentencing. “He was asked only to help locate Al Qaeda terrorists, who threaten Pakistan and the U.S. He helped save Pakistani and American lives.”

On Capitol Hill, two of the Senate’s leading voices on national security, Carl Levin, Democrat of Michigan, who is the chairman of the Armed Services Committee, and John McCain of Arizona, the panel’s ranking Republican, angrily denounced the court’s sentence. “What Dr. Afridi did is the furthest thing from treason,” the senators said in a statement. “It was a courageous, heroic and patriotic act, which helped to locate the most wanted terrorist in the world — a mass murderer who had the blood of many innocent Pakistanis on his hands.”

In January, Defense Secretary Leon E. Panetta confirmed that the United States had been working with Dr. Afridi while trying to verify the location of Bin Laden’s compound in Abbottabad in the months before the raid. American officials previously said that the doctor had been running a hepatitis B vaccination program as a ruse to obtain DNA evidence from Bin Laden’s family, thought to be hiding in the city. American officials say Dr. Afridi did not know the identity of his target.

According to Pakistani security officials, Dr. Afridi admitted to helping the C.I.A. before the raid by Navy SEALs that killed Bin Laden last May. That operation angered Pakistani officials, who had not been informed ahead of time and viewed it as a violation of the country’s sovereignty.