KABUL, Afghanistan - An Afghan soldier shot and killed two U.S. troops yesterday outside a top-security prison being revamped to house Afghans transferred from the Guantanamo Bay detention camp, a U.S. military spokesman said.

The gunman was shot dead by other Afghan troops at Pul-e-Charkhi prison, about 20 miles east of Kabul, said Maj. Sheldon Smith, a spokesman for Combined Security Transition Command, which trains Afghan security forces. The shooter also wounded two U.S. soldiers.

The Americans were working as mentors to Afghan troops providing external security for the prison, Smith said. U.S. and Afghan authorities were trying to determine the motive for the attack, he said.

"All indications are" that the shooter was a member of the Afghan National Army, the post-Taliban force trained mainly by the U.S. military, Smith said.

"The ANA are our partners here, and they are working side by side with us in conducting this investigation," Smith said.

He said the U.S. soldiers were in two vehicles when they were shot. The victims were not identified, and Smith provided no further details of the incident.

Afghan soldiers, with their U.S. trainers, have been deployed at the prison in connection with the setting up of a high-security wing, Smith said. The wing, which opened last month, is designed to eventually house Afghans transferred from the U.S. military prison at Guantanamo Bay, Cuba.

The changes are supposed to improve security at the grim concrete jail, which is infamous among Afghans for tales of torture and appalling conditions dating back to communist rule in the 1970s.

Since the U.S.-led invasion that toppled the Taliban, hundreds of al-Qaeda and Taliban suspects have been incarcerated there. Some have been involved in a series of deadly riots and breakouts.

The jail has one American inmate, a former soldier called Jonathan "Jack" Idema, who was arrested in July 2004 and convicted of running a private prison in Kabul.

Idema is expected to be released soon. Two other Americans arrested along with him were freed last year.