A Pakistani court imposed a 33-year sentence Wednesday on a doctor who assisted the CIA in the hunt for Osama bin Laden, prompting dismay among U.S. officials and warnings that the punishment will exacerbate strained relations and could lead to cuts in aid.

Shakil Afridi, 48, a government surgeon in the semiautonomous Khyber Agency along the border with Afghanistan, was convicted of treason for using a vaccination drive to try to gather DNA samples from the Abbottabad compound where bin Laden was in hiding.

Afridi failed to obtain the samples and didn’t know the target of the program, but U.S. officials said he nonetheless contributed to an intelligence operation that culminated in the May 2, 2011, killing of bin Laden by a Navy SEAL team.

U.S. officials depicted Afridi as a patriot and said his actions saved both Pakistani and American lives. But in Pakistan, where the U.S. incursion deep into the country led to national hand-wringing and anger, Afridi was widely excoriated as a traitor.

The CIA declined to comment Wednesday on Afridi’s sentence. But a senior U.S. official with knowledge of counterterrorism operations in Pakistan said the surgeon “was never asked to spy on Pakistan.”

“He was asked only to help locate al-Qaeda terrorists, who threaten Pakistan and the U.S.,” the official said. “His activities were not treasonous; they were heroic and patriotic.”

Pentagon spokesman George Little said, “Anyone who helped the United States find bin Laden was working against al-Qaeda and not against Pakistan.”

In a joint statement, Sen. Carl Levin (D-Mich.), chairman of the Armed Services Committee, and Sen. John McCain (Ariz.), the ranking Republican on the committee, called the sentence “shocking and outrageous” and urged Pakistan to pardon Afridi and release him immediately.

“What Dr. Afridi did is the furthest thing from treason. 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,” the senators said.

They warned that “Dr. Afridi’s continuing imprisonment and treatment as a criminal will only do further harm to U.S.-Pakistani relations, including diminishing Congress’s willingness to provide financial assistance to Pakistan.”

Recent tensions

Afridi was arrested several weeks after the killing of bin Laden. The doctor was eventually tried under a tribal judicial system that denies the accused the right to have an attorney or to present evidence.

Under a recent change to Pakistan’s much-despised criminal codes, created more than a century ago by the British rulers of the Indian subcontinent to put down tribal revolts, Afridi has the right to appeal to an agency tribunal.

Afridi was remanded to a jail in the city of Peshawar and ordered to pay a fine of about $3,500, Khyber Agency officials said.

He could have received the death penalty if he had been tried under normal Pakistani law, but even so, the harsh sentence has added to tensions between Islamabad and Washington over issues that include ongoing CIA drone strikes and deadly exchanges between U.S. and Pakistani forces on the border with Afghanistan.

For six months, Pakistan has blocked NATO supply convoys from crossing its territory into Afghanistan, in retaliation for U.S. airstrikes that killed 24 Pakistani soldiers at two border outposts in November. On Tuesday in Washington, a Senate panel approved a foreign aid budget that would cut U.S. assistance to Pakistan by more than half and allow deeper reductions if Pakistan does not reopen the supply routes.

Despite the recent tensions, Gen. John R. Allen, the top U.S. commander in Afghanistan, said the relationship with Pakistan is showing signs of improvement. Allen recently traveled to Islamabad to discuss how to better coordinate military operations along the border with Afghanistan and the reopening of ground supply lines through Pakistan.

“We hadn’t had a conversation with them in almost a year on that level,” Allen said at a Pentagon news conference Wednesday. He said the meetings left him with the impression that relations were “poised to improve.”

In defense of the doctor

Muhammad Nasir Khan, an assistant political agent in the Khyber Agency, said Afridi was convicted of helping a foreign country after a three-month trial. The formal charges included cooperation in war against the state and interference in state affairs.

A Pakistani government commission tasked with reviewing intelligence failures related to the Abbottabad raid had recommended that Afridi be tried for treason. The government has fired 17 other health workers who assisted in the vaccination program.

Secretary of State Hillary Rodham Clinton told the House Foreign Affairs Committee two months ago that Pakistan had no basis for holding Afridi. “His work on behalf of the effort to take down bin Laden was in Pakistan’s interests as well as in America’s,” she said.

Defense Secretary Leon E. Panetta, speaking on CBS’s “60 Minutes” in January, called Afridi’s detention “a real mistake” by Pakistani authorities.

Rep. Dana Rohrabacher (R-Calif.) also has championed Afridi’s case, submitting a bill to grant him U.S. citizenship. “This bill shows the world that America does not abandon its friends,” he said.

The measure went nowhere, but Rohrabacher’s calls for Congress to cut off all aid to Pakistan, including $2.2 billion already authorized, are resonating more widely.

“Any money that goes to Islamabad will continue to end up in the pockets of people actively and deadly hostile to America,” he said in a statement Wednesday in response to Afridi’s sentencing. “The Taliban is only the tip of the spear; the real enemy is Pakistan.”

Finn reported from Washington. Special correspondents Haq Nawaz Khan in Peshawar and Shaiq Hussain in Islamabad and staff writers Greg Miller, Greg Jaffe and William Branigin in Washington contributed to this report.