ISLAMABAD - Most legal experts in Pakistan's government believe an American detained in the killing of two Pakistanis has diplomatic immunity, but a court should decide his fate, an official said Tuesday. The announcement reflected an apparent bid to open the way to the man's release while dampening public outrage.

Raymond Allen Davis has been held by Pakistani authorities since he fatally shot two Pakistanis in the eastern city of Lahore on Jan. 27, and his case has become a bitter point of contention between Washington and Islamabad, whose relationship is considered key to ending the war in Afghanistan.

The U.S. says Davis, a former Special Forces soldier and an embassy worker, shot in self-defence when two armed men on a motorcycle tried to rob him and that his detention is illegal under international agreements covering diplomats. U.S. officials have threatened to withhold billions of dollars in aid to Pakistan unless Davis is freed.

U.S. Sen. John Kerry arrived in Pakistan late Tuesday to discuss the case with senior Pakistani officials, the U.S. Embassy said.

Pakistani government officials had avoided a definitive stand on Davis' legal status in the face of popular anger over the shootout. Thousands have rallied against Davis, demanding he be hanged, while the Taliban have threatened attacks against any Pakistani official involved in freeing the 36-year-old Virginia native.

It hasn't helped that the government of Punjab province, where any trial would be held, is run by a party that is a rival to the one running the federal government.

Aslam Tareen, police chief in Lahore, Punjab's capital, declared last week that a police investigation determined Davis had committed "an intentional and cold-blooded murder."

Police officers determined the pistol of one of the slain men was loaded but no round was in the chamber, and that the American shot the second Pakistani in the back, killing him as he tried to flee, Tareen said.

However, a Pakistani federal government official told The Associated Press on Tuesday that after reviewing the matter, most experts in Pakistan's legal and foreign offices believe Davis is immune from prosecution.

The government is expected to give documents laying out the opinions to the Lahore High Court during a hearing about Davis' status on Thursday.

Government officials want the court to make a final ruling on the subject of Davis' immunity, the Pakistani official said, speaking on condition of anonymity because of the subject's sensitivity. He said that after seeing the records, it will be difficult for the court to deny Davis immunity, though Pakistani courts can be unpredictable.

The official noted concern in the government over popular anger if Davis is freed. He said many leaders have been fearful since January, when a bodyguard killed a liberal Pakistani governor who wanted to reform harsh laws that impose the death sentence for insulting Islam.

The official also said that Kerry, the chairman of the U.S. Senate Foreign Relations Committee, was expected to issue a statement of regret over the incident, though American officials would not confirm that.

The Obama administration asked Kerry to make the trip amid the deterioration in relations between Washington and Islamabad over the Davis case, according to a Congressional official in Washington who spoke on condition of anonymity because he was not authorized to discuss details of the visit publicly.

The official said Kerry did not go to bring Davis back to the U.S. and there was no expectation that he would do so because the Pakistanis have made clear that Davis will not be released in the short term, or at least until the court case against him is resolved.

Kerry "is there to tone down the rhetoric and reaffirm our partnership," the official said.

U.S. officials in Islamabad declined to comment on the Pakistani government's plans. In Washington, State Department spokesman P.J. Crowley has said the U.S. on Thursday "will present a petition to the court to certify that (Davis) has diplomatic immunity and that he should be released."

Nonetheless, Crowley said the courts should not be involved in accordance with the Vienna Convention regarding the status of diplomats.

There has also been controversy in Pakistan over the fact that Davis was armed. A senior U.S. official has told The Associated Press that Davis was authorized by the United States to carry a weapon, but that it was a "gray area" whether Pakistani law permitted him to do so.

The U.S. has not stated specifically what Davis' job is, other than saying he's a part of the embassy's "administrative and technical staff," which leaves room for the possibility that he works in security.

In a video clip aired by a private Pakistani channel, Davis is seen telling Pakistani police that he works for the embassy and that he was a consultant for the U.S. consulate in Lahore. He also says he works for the RAO -- an apparent reference to the Americans' Regional Affairs Office.

The authenticity of the video could not be independently verified.

The U.S. Embassy says Davis has a diplomatic passport and a visa valid through June 2012, and that Pakistan was notified of Davis' assignment more than a year ago.

After the shootings in Lahore, Davis called for backup. The American car rushing to the scene hit a third Pakistani, a bystander, who later died.

Crowley, the State Department spokesman, said Monday that U.S. Embassy staff were in the vehicle. Pakistani police have said they want to question the car's driver and passengers as well, though it is highly unlikely those staffers -- especially if U.S. citizens -- are still in Pakistan.