Videotapes released Thursday by a federal court show mentally ill prisoners in California being forced from their cells by guards who douse them repeatedly with pepper spray.

Some of the inmates are being forced to comply with medication orders; others are to be moved to new cells.

The six tapes, created by guards abiding by a state policy to record all cell extractions, were shown in court in October as part of a lawsuit by inmates' lawyers seeking a ban on the use of pepper spray against the mentally ill. The tapes were ordered released by U.S. District Judge Lawrence Karlton, who is holding hearings on the issue in Sacramento.

In one tape shot in July of last year at California State Prison at Corcoran, a screaming, naked prisoner is sprayed five times in 15 minutes before being tackled to the ground by about half a dozen guards and then strapped to a gurney.

His prison psychiatrist testified that the psychotic inmate had lost touch with reality and needed emergency medication.

"When we order involuntary medications, the inmate is told they will receive medications whether they like it or not," said the psychiatrist, Dr. Ernest Wagner.

Lawyers representing some 30,000 mentally ill prisoners say the tapes show excessive force, the abuse of men who may have little understanding of what is happening to them or why.

"The mentally ill are being punished for their mental illness," Jeffrey Bornstein, a San Francisco attorney representing inmates, told the judge.

Witnesses for the state, including California's director of adult prisons, said in court that in all of the taped incidents guards followed proper procedure. It is safer to remove prisoners from their cell at a distance rather than use physical force, they said.

The corrections department filed the videos with the court Thursday and issued a statement calling the use of force "always a last resort for our staff."

Extracting inmates from their cells is typically done to keep them "from harming themselves or others and to ensure that they are placed in a more appropriate mental health setting," the statement said.

"What you don't see on these videos," it said, "is the hours of discussions that take place between the inmate and clinical staff before a cell extraction is ordered and the video camera starts rolling."

The agency said that it is in the process of revising rules to limit the amount of pepper spray used at any one time.

The 31-year-old inmate in the footage from Corcoran last July had been suicidal, Wagner testified — refusing to eat food, consuming his feces and hearing voices. Eventually the court ordered the man medicated, and he was brought out of his cell to have the drugs administered.

Without the medication, Wagner told the court, the prisoner "would have died."

After being removed from his cell, the inmate remained strapped down, under Wagner's orders.

He was released when a different doctor came on duty and then was moved to an isolation cell, according to medical files read in court. His prison sentence was extended by three months as punishment for refusing orders.

In November of last year, the inmate was admitted to a prison psychiatric hospital, where his condition improved, court documents show. He was then returned to the general prison population and paroled in February, according to courtroom testimony.

Karlton had ordered that the names of prisoners be removed or covered up in the videos, out of concern for their medical privacy. The state also obscured the names of all staff involved in the incidents.

Three of the six tapes were aired in court without editing. The others had only the names of inmates blocked or erased.