A former CIA contractor broke both agency rules and the law when he used a two-foot metal flashlight to beat an Afghani who later died, a US court heard.

David Passaro (40) is the first American civilian charged with mistreating a detainee during the US wars in Iraq and Afghanistan.

Lawyers for Passaro said the former special forces medic, who was working under contract to the CIA, never hit Abdul Wali and checked daily on his condition.

"Dave is guilty only of trying to serve his country," Joe Gilbert, Passaro's public defender, said during opening arguments in Raleigh, North Carolina. "He's not guilty."

Although Wali died in his cell, Passaro is not charged in connection with his death, but with two counts of assault with a dangerous weapon and two counts of assault resulting in serious injury. If convicted, he will face up to 40 years in prison.

Prosecutors told the jury that at least three paratroopers from the US Army's 82nd Airborne Division watched Passaro beat Wali in June 2003 during two days of questioning about rocket attacks on a remote base housing US and Afghan troops.

Assistant US Attorney Pat Sullivan said Passaro told the soldiers they could not touch Wali, but that he could, "because I have special rules".

"David Passaro had no special rules," Sullivan said. "He made them up."