Pakistan’s decision Wednesday to release a CIA contractor accused of killing two men resolved a standoff that threatened to damage diplomatic relations between Islamabad and Washington, but it triggered new protests in Pakistan that reflected rising hostility from the United States’ key counterterrorism ally.

Raymond A. Davis was freed from a jail in Lahore after relatives of the Pakistani victims received as much as $2.3 million in “blood money” compensation.

Davis, a CIA security guard, was pardoned and flown to a U.S. facility in Kabul, where he was to be examined and questioned about his treatment before returning to the United States.

Secretary of State Hillary Rodham Clinton expressed gratitude to the victims’ families in Pakistan and said that the Justice Department has begun an investigation of the shooting that led to Davis’s arrest in Lahore on Jan. 27.

Clinton insisted that the United States had not made any payment to the families or agreed to reimburse the Pakistani government. But other U.S. officials signaled that Washington had endorsed the “blood money” payments and that it expects to reimburse Pakistani authorities, who had led an effort in recent weeks to persuade the Pakistani families to accept cash in return for dropping the case.

“We expect to receive a bill,” a U.S. official said.

The release stunned Pakistanis, and opponents accused President Asif Ali Zardari’s government of bowing to U.S. pressure.

Hundreds of angry protesters tried to gather outside the U.S. Consulate in Lahore, where they were beaten back by police, and religious groups said they planned nationwide protests Friday.

“The judge who released Davis murdered law and justice,” said Sen. Khurshid Ahmad of Jamaat-e-Islami, the nation’s largest religious-based political party. He said that federal, provincial and security officials had connived to free Davis, and that “blood money was taken not just for two men, but the whole country was sold.”

Pakistani officials denied that they had capitulated. Information Minister Firdous Ashiq Awan said the Zardari government had always said it would leave the decision up to the courts.

Pakistan’s government had been buffeted by pressure from all sides, reluctant to appear pressured by Washington, but eager to close a case that called attention to the extensive CIA presence inside the country and risked a rupture with a source of billions of dollars in aid.

Obama administration officials expressed hope that the resolution of the case would allow diplomatic repair work to begin. The trilateral U.S.-Pakistan-Afghanistan talks that had been canceled last month will now be rescheduled, officials said.

The CIA and its Pakistani counterpart, the Inter-Services Intelligence (ISI) directorate, are also expected to hold talks aimed at reducing friction over the scope of CIA activity in the country.

A U.S. official insisted, however, that the CIA had not made any concessions to get Davis, 36, released. “There was no quid pro quo between the Pakistani and U.S. government” in connection with the case, the official said.

The official and others spoke on the condition of anonymity because they were not authorized to discuss details of the case.

The CIA has carried out more than 100 drone strikes against militant groups in Pakistan’s tribal territories over the past year — strikes that are secretly authorized by the Pakistani government.

At the time of his arrest, Davis was serving as a security guard for a team of CIA operatives gathering intelligence on militant organizations in Lahore, including Lashkar-i-Taiba, a group that has carried out deadly attacks against India and has long been backed by the ISI.

A former U.S. Special Operations soldier and employee of the private security firm known as Blackwater, Davis said he fired in self-defense after being approached by two armed men on a motorcycle in an apparent robbery attempt at a traffic signal.

U.S. officials initially asserted that Davis was merely a State Department employee entitled to diplomatic immunity. President Obama called him “our diplomat” and argued that he should be released. But Pakistani officials disagreed.

From the beginning, the details of the case — including the fact that Davis was arrested while in possession of a 9mm weapon, a camera, a telescope, a headlamp and other espionage gear — fueled speculation that he was a spy.

Negotiations to resolve the dispute began in earnest three weeks ago, when Senate Foreign Relations Committee Chairman John F. Kerry (D-Mass.) made a surprise trip to Pakistan at the administration’s request to try to ease tensions.

A broad agreement was reached last Friday to make blood money payments to the families, but officials said there were concerns that it might unravel as the families argued about the terms.

Such payments are incorporated into Pakistan’s statutes under “compensation and forgiveness” provisions of sharia law.

U.S. Ambassador Cameron Munter accompanied Davis on the flight to Kabul. A senior U.S. official said Davis was flown there because the United States wanted him out of Pakistan as soon as possible and “it was the closest place.”

The official said Davis was in “good spirits” but was not immediately asked to speak in detail about the shootings or his time in custody. “We wanted to leave that to the professionals,” the official said.

It was not immediately clear how soon Davis will be flown to the United States. A man who answered the phone at Davis’s sister’s house said the family would offer no comment on his release.

According to his 2009 visa application, Davis was born in Wise, Va. He gave an address in Las Vegas, where he is listed in Nevada state records as co-owner of Hyperion Protective Services, apparently a private security firm.

In addition to the two men killed by Davis, a third Pakistani died after being struck by a vehicle carrying CIA personnel attempting to retrieve Davis after the shooting. It is unclear whether any money was offered to the family of that pedestrian.

Constable reported from Lahore. Staff writers Karen DeYoung in Washington and Ernesto Londono in Kabul, and researcher Julie Tate in Washington, contributed to this report. Shaiq Hussein, a special correspondent, reported from Islamabad.