Alexandria County Sheriff's Dept. / AP file John Walker Lindh is seen in a file photo originally released by the Alexandria County Sheriff's Department in Alexandria, Va. The photo was made on Jan. 23, 2002.

Updated at 3:30 p.m. ET: American-born Taliban fighter John Walker Lindh testified Monday that the U.S. government is forcing him to sin by denying him the right to pray daily with other Muslims in the highly restricted federal prison unit where he is detained.

He made his comments during the first day of a closely watched trial that will examine how far prison officials can go to ensure security in the age of terrorism.

Lindh was captured in Afghanistan and imprisoned in the United States after the September 11, 2001, terror attacks on the United States by Islamic extremists.

Lindh testified in federal court in Indianapolis that the Terre Haute, Ind., prison where he's serving a 20-year sentence for aiding Afghanistan's Taliban government before its overthrow allows prisoners to eat, talk, play cards and exercise together, but bans daily group prayer. He contends this violates a 1993 law barring the government from curtailing inmates' religious expression without showing it has a compelling interest.

Lindh, 31, adheres to a school of Islam that requires group prayer five times a day, if possible.

"I believe it's obligatory," Lindh said. "If you're required to do it in congregation and you don't, then that's a sin."

Attorneys for the government maintain that Lindh's own behavior since he was placed in the unit in 2007 proves the risks of allowing group prayer.

The government says in court documents that Lindh delivered a "radical, all-Arabic sermon" to other Muslim prisoners in February that was in keeping with techniques in a manual seized from al-Qaida members that details how terrorists should conduct themselves when they are imprisoned.

Lindh's sermon proves "that religious activities led by Muslim inmates are being used as a vehicle for radicalization and violence in the CMU," the government claims.

The prison warden halted daily group prayers in 2009 and allowed them only on the holy day of Friday.

Lindh accuses the government of going too far in its drive for security and trampling on his freedom of religion by restricting group prayers among Muslim inmates.

A cluster of U.S. marshals surrounded a shackled Lindh as he was brought into the courtroom on Monday morning. He was wearing an olive green prison uniform and a white prayer cap. He smiled at his mother, who was sitting in the third row of the courtroom gallery.

The bearded Lindh was led out after two hours of testimony.

With the help of a glossary for court officials, Lindh guided the court through a series of lessons on Muslim prayer traditions.

Lindh has been held in the federal unit at Terre Haute since 2007. He was charged with supporting terrorists after his capture by U.S. troops in Afghanistan and later pleaded guilty to lesser charges.

Muslims are required to pray five times a day, and the Hanbali school to which Lindh belongs requires group prayer if it is possible. But inmates in the Communications Management Unit are allowed to pray together only once a week, except during Ramadan. At other times, they must pray in their individual cells. Lindh claims that doesn't meet the Quran's requirements and is inappropriate because he is forced to kneel in close proximity to his toilet.

Thomas Farr, a former diplomat who now teaches at Georgetown University and studies religion and terrorism, said common sense suggests that the prison's need for security would outweigh Lindh's religious rights.

"The foremost responsibility of prison officials, as de facto proxies for the American people, is to prevent Mr. Lindh from obtaining any capacity to plan or carry out attacks on them," he wrote in an email. "That is why he is in prison, and if that is not a compelling state interest, I do not know what is."

Watch the most-viewed videos on NBCNews.com

The American Civil Liberties Union of Indiana, which is representing Lindh, contends the policy violates a federal law barring the government from restricting religious activities without showing a compelling need.

"This is an open unit where prisoners are basically out all day," said ACLU legal director Ken Falk, who noted that inmates are allowed to play basketball and board games, watch television and converse as long as they speak English so the guards can understand. "They can do basically any peaceful activity except praying," he said. "It makes no sense to say this is one activity we're going to prohibit in the name of security."

Falk said Lindh's speech wasn't radical and was given during the weekly prayer that inmates are permitted. He said Lindh was not disciplined for the speech.

Stay informed with the latest headlines; sign up for our newsletter

The self-contained unit in which Lindh resides has 43 inmates, 24 of whom are Muslim. Inmates are under open and covert audio and video surveillance, and except for talks with their attorney, all of their phone calls are monitored. Prisoners are not allowed to touch their family members when they come for their tightly limited visits. They must speak English at all times except when reciting ritual prayers in Arabic.

Without such tight security, the government claims, the prisoners would be able to conspire with outsiders to commit terrorist or criminal acts.

Joe Hogsett, the U.S. attorney for the Southern District of Indiana, said he believes decisions about prison regulations are best made by prison officials, "not by convicted terrorists and other dangerous criminals who reside there."

"Mr. Lindh is allowed to pray in his cell; he's allowed to pray wherever he happens to be as many times every day as his religion suggests to him that he should," Hogsett said. "Where the rules must draw the line is, how often must prison officials allow prisoners to congregate together?"

According to court documents, daily prayers were allowed from the time the unit opened in 2006 until May 2007, when Muslim inmates refused to stop in the middle of a prayer to return to their cells during a fire emergency.

The lawsuit was originally filed in 2009 by two Muslim inmates in the unit. Lindh joined the lawsuit in 2010, and the case has drawn far more attention since then. The other plaintiffs have dropped out as they were released from prison or transferred to other units.

Lindh had been charged with conspiring to kill Americans and support terrorists, but those charges were dropped in a plea agreement. He is serving a 20-year sentence for supplying services to the now-defunct Taliban government of Afghanistan and carrying explosives for them. He is eligible for release in 2019.

The Associated Press and Reuters contributed to this report.

More content from NBCNews.com:

Follow US News from NBCNews.com on Twitter and Facebook

Follow Kari Huus on Facebook