INDIANAPOLIS (AP) — The warden of a U.S. prison holding high-risk inmates, including American Taliban fighter John Walker Lindh, insisted Thursday that he was obeying a court order to allow daily group prayer by permitting inmates to pray in pairs within their cells.

Warden John Oliver told a federal judge that when the prison allowed group prayer earlier this year, Muslim inmates formed gangs and bullied other prisoners.

Lindh attended the hearing by video conference from the high-security unit that houses him and about 40 other inmates, including several convicted on terror charges.

A U.S. District judge ruled in January that barring Lindh and his fellow Muslims from engaging in daily group prayer violates a 1993 law that bans the government from curtailing religious speech without showing a compelling interest. The judge issued an order demanding that the prison allow group prayer.

Ken Falk, legal director of the American Civil Liberties Union of Indiana, filed a motion in Lindh's name in April asking the judge to find the prison warden in contempt. The motion argued that the warden allowed only three group prayers per day in a single room, instead of the five that Lindh said his faith requires.

But Oliver said he believed he was balancing inmates' religious rights with the security needs of the special unit that severely restricts inmates' communications with the outside world.

The prison converted a recreation room into a "meditation room" to accommodate group prayer in March, but Muslim inmates, who make up more than half of the 42 people in the unit, used the inmate-led prayers to set up a prison gang, Oliver said.

Some Muslim inmates "shunned" others by banning them from the prayer group, controlled access to food and claimed the room as their territory by leaving prayer rugs and other religious items there. Oliver said this intimidated inmates of other faiths and deterred them from using the room.

In response to what Oliver called "gang activity," he changed the rules in May, barring use of the meditation room for group prayer and limiting prayer to two inmates per single cell, which he said was more secure.

The judge said she will rule later on whether the prison has violated her order.

U.S. troops captured Lindh in Afghanistan in 2001. Lindh, who was raised Catholic, was accused of fighting for the Taliban to help them build a pure Islamic state. In 2002, he pleaded guilty to supplying services to the now-defunct Taliban government and carrying explosives for them. He is eligible for release from prison in 2019.