An Afghan court sentenced Jonathan "Jack" Idema and two other Americans to lengthy prison terms Wednesday, finding them guilty of running a private prison and torturing Afghan detainees in what the defendants claimed was a legitimate operation to round up terrorists.

Idema, 48, of Fayetteville, N.C., the group's leader and a former member of the U.S. Army Special Forces, was given a 10-year term, as was his younger associate Brent Bennett. A third man, Edward Caraballo, a journalist, received eight years, while four Afghan employees of the group were sentenced to between one and five years.

The defendants, represented by two American lawyers, presented several videotapes and documents in court that appeared to strengthen their claim that senior U.S. and Afghan officials knew of their covert operations and in some cases assisted them. U.S. military authorities here have denied any involvement with Idema and his associates aside from receiving one prisoner from them; Afghan officials who dealt with them have said they believed the group was operating with U.S. government approval.

Idema and the others were arrested in July in a police raid on their quarters in Kabul, where eight Afghan prisoners were found. The defendants said the prisoners were terrorists who had plotted to kill Afghan officials with car bombs; the detainees have testified in court that they were innocent citizens who had been tortured.

In one tape shown Wednesday, Idema and the others were shown being warmly greeted by several Afghan officials, including Kabul's police chief, when their plane landed in April. In another, they were shown discussing their work against terrorists with a U.S. Army officer; in several more tapes, Idema was shown in telephone conversations with people he claimed in court were U.S. intelligence and military officials.

Idema also recited a lengthy history of his military and intelligence missions in Afghanistan after the U.S.-led ouster of the Taliban in 2001, saying he had been issued a U.S. passport by a "special government agency" and an unlimited military visa by Afghan officials.

He named as his associates virtually every senior commander in the Afghan militia that worked with the U.S. military in its pursuit of Osama bin Laden and Taliban forces, in some cases receiving U.S. medals for their efforts.

"I operated in this country for three years at the highest levels," Idema told the court. "I can assure you that at no time did we ever conduct an operation . . . without prior approval of the corps commanders and in most cases the governors." But Judge Abdulboset Bakhtiary expressed increasing impatience with the rambling presentation of evidence and asked the defense to stick to the charges at hand.

After about five hours of legal wrangling and constantly interrupted testimony, the judge called a short recess. When the session resumed, he read out a long verdict that had evidently been prepared before the hearing.

Reviewing points from five previous hearings in the case, Bakhtiary concluded that the defendants built a "private network" of relationships in Afghanistan but did not obtain official approval, and that their stealthy mode of operation, including establishing a false business and constantly shifting homes, proved they did not want people to know what they were doing.

As in the earlier hearings, Wednesday's court session was a roller coaster of theatrical outbursts by Idema, arguments between the defendants and the court interpreter, interruptions by the judge and legal lectures and objections by the American attorneys for Idema and Caraballo.

At one point Idema insisted on taking an oath before testifying, putting his hand on a copy of the Koran and reciting a prayer in Arabic. Suddenly, an Islamic cleric in the front row of the gallery -- whom Idema once imprisoned and accused of being a terrorist -- jumped up and led an audience cheer to celebrate Idema's apparent on-the-spot conversion to Islam.

Within minutes, though, Idema had offended every Muslim in the court by showing a video of himself swearing loudly into a telephone. The court interpreter, an Afghan law professor, told the judge he would rather quit than speak the obscenities.

During breaks in the hearing, Idema held court from the defendants' dock, chain-smoking as he sat on the railing and tossing out unprintable quips to a throng of journalists and camera crews below.

During the hearing, the defense attorneys also injected numerous dramatic moments, shouting "That is a lie!" or "This is illegal!" They made sarcastic asides to the packed courtroom and demanded that the trial be halted.

The attorneys also attempted to have the case thrown out on grounds that the judge, the court and the Afghan legal system were inadequate to the task.

Robert Fogelnest, Caraballo's attorney, began reading a long statement arguing the charges should be dropped because "the legal system in Afghanistan is not yet fully functional and the rule of law is not yet fully established." But Bakhtiary cut him off, saying he should get to the facts of the case.

The rest of the unread statement, which the attorneys later distributed to the press, said the defendants believed they had been framed by the FBI in retaliation for refusing to share intelligence.

Outside the courtroom later, Fogelnest said the three Americans would appeal the verdict. He protested that the defense had not been allowed to make its case and said the U.S. government was to blame for allowing the men to be tried in an incompetent foreign court.

Jonathan "Jack" Idema led group.