Fifty years ago, more than half a million mentally ill Americans lived in state-run mental hospitals like the one depicted so searingly in One Flew Over the Cuckoo's Nest. Today, laws protect the mentally ill from needless involuntary stays. As a result, fewer than 80,000 people now live in such institutions.

The revolution in mental-health care, called "deinstitutionalization," has not, however, lived up to its promises. It is true that mentally ill persons are far less likely to be confined in the bleak, punitive, overcrowded and counterproductive warehouses that passed for hospitals decades ago. Unfortunately, though, it is also true that they are far more likely to be confined in the bleak, punitive, overcrowded and counterproductive warehouses that are U.S. prisons.

Somewhere between 200,000 and 300,000 people currently live behind bars with a serious mental illness, including schizophrenia, bipolar disease and major depression. Tens of thousands of these men and women are actively psychotic on any given day. The rate of mental illness among the incarcerated population is as much as three times higher than the rate among the general population.

But there's good news: On Oct. 27, the U.S. Senate overwhelmingly passed the Mentally Ill Offender Treatment and Crime Reduction Act. Sponsored by Sen. Mike DeWine (R-Ohio) and co-sponsored by several senior Democrats and Republicans, the bill allocated millions of dollars in federal funds to pilot programs designed to facilitate collaboration between mental-health services and the criminal-justice, juvenile-justice and corrections systems, with the express intent of diverting mentally ill offenders away from the country's prisons. The act also provides for seed money for the promotion of transitional programs for mentally ill prisoners re-entering the community. So far the House has not voted on the legislation, which is sponsored by Rep. Ted Strickland (D-Ohio), although supporters hope it will do so in the coming months. If the bill becomes law, it has the potential to save mentally ill people from the Dickensian conditions they're now living under.

Some mentally ill prisoners have been left covered in feces for days; others have had to drink toilet water during hot summer months because there is no other drinking water; still others have lived in cells that corrections experts have labeled "medieval." The rooms are ancient, dark, cramped, filthy and poorly ventilated. Prisoners have spent days naked, shivering and alone in observation cells after attempting suicide.

Many are silent in their cells, mumble incoherently or yell incessantly; they refuse to obey orders or lash out without apparent provocation; they beat their heads against cell walls, smear themselves with feces and mutilate themselves. Some are riddled with scars from self-injury.

But in the bizarrely punitive world of prisons, self-mutilation and attempted suicide are rules violations rather than cries for help. Tearing sheets into strips to serve as a noose, for example, is "destruction of state property," a punishable offense.

In Illinois, an inmate at Tamms supermax prison who had begun eating the flesh from his own arm was sentenced to one year in an isolation unit. As stated in the technocratic jargon of prison paperwork: "Offense: 104. Violation: Dangerous Contraband. Comments: Piece of Glass. Final Result: Guilty. Record of Proceedings: Inmate appeared before the committee to address the charges. Inmate stated: 'I'm guilty. I was hungry and I was eating my arm that day. I found the piece of glass in my cell after I busted my light out.' Disciplinary action: Segregation one year."

Unable to handle inmates' unique needs, corrections officials end up placing the mentally ill who act out or are disruptive in segregation, what used to be called solitary confinement. Suicidal inmates are typically confined in solitary isolation units, enduring the same harsh conditions as meted out to willful offenders who, for example, sell drugs inside a prison. Spending years locked in a small cell 24 hours a day -- except for a few hours per week for solitary recreation -- and with nothing to do can tax the coping skills of anyone. It can and often does drive the mentally ill over the edge. They fall apart and are taken to a hospital for intensive inpatient care. But, once stabilized, they are returned to the same unbearable conditions of segregation, and the cycle of suffering begins again.

The incarceration of the mentally ill was not the future dreamed of by the architects of deinstitutionalization. How did it happen?

The starting point is the underfunded and fragmented nature of community mental-health services.

On Oct. 29, 2002, the New Freedom Commission on Mental Health, created by George W. Bush, sent the president an interim report. Chairman Michael F. Hogan described the commission's findings: "America's mental health service delivery system is in shambles. We have found that the system needs dramatic reform because it is incapable of efficiently delivering and financing effective treatments -- such as medications, psychotherapies and other services -- that have taken decades to develop. Responsibility for these services is scattered among agencies, programs and levels of government. There are so many programs operating under such different rules that it is often impossible for families and consumers to find the care that they urgently need."

As a result, hundreds of thousands of mentally ill people who need public mental-health services do not get them. Some of these mentally ill people will commit crimes and then get involved with the criminal-justice system. They oftenend up sentenced to time in either jail or prison.

This problem has been made far worse by broader incarceration policies adopted over the past three decades. More people with serious mental illnesses are going to prison because more Americans in general are now being incarcerated under tough-on-crime legislation such as mandatory minimum-sentencing laws that require prison even for many low-level, nonviolent crimes. As the U.S. prison population has soared, so has the number of incarcerated offenders with mental illnesses.

Prisons were never intended as facilities for the mentally ill. But with a national rate of mental illness among prisoners estimated by the Department of Justice at 16 percent, providing mental-health services is now a major part of running prisons.

Yet most prison systems, lacking adequate mental-health service budgets, employ far too few psychiatrists, licensed psychologists and other qualified mental-health professionals. The shortage of staff means prisoners who need help confront delays before getting to see a mental-health professional, time with those professionals is rushed and rare, and treatment typically consists only of medication and not the range of programs that mentally ill persons need.

"That's a common problem across states," says Dr. Jeffrey Metzner, correctional mental-health expert and clinical professor of psychology at the University of Colorado's Health Sciences Center. "Most psychiatrists' roles are limited to medication management due to resource issues. The amount of psychotherapy available is very limited. There aren't enough qualified people, or you might have a bunch of mental-health clinicians without proper qualifications."

Even medication can be problematic. It is disrupted when prisoners change facilities, supplies can be erratic, and many prisons avoid using the newer and more effective medications prescribed in the community because they are more expensive. Side effects are not carefully monitored, and when prisoners discontinue their medication -- as many people with mental illness do -- there is little effort to persuade them to start again, much less to listen to the concerns that prompted them to stop in the first place. Those who discontinue their medications are sometimes simply dropped from the mental-health caseload, even though they remain desperately ill.

One inmate, identified as "R.P.," was interviewed in the secure housing unit of New York's Wende prison. "Sometimes I have feelings of killing myself," he said. "Nobody to talk to. It's horrible all round. I sit there, look at the walls, talk to myself about things I want to do -- hurting people, hurting correctional officers, hurting other inmates."

Over the past couple of years, he has cut himself with razors, tried to hang himself and swallowed hoarded painkillers. At times he has been removed to psychiatric wards, only to be returned to isolation upon stabilizing.

"It used to be the state hospital couldn't turn down anybody," says Richard Lamb, professor of psychiatry, law and public policy at the University of Southern California. "Now the state hospitals can and do. Today the jails and prisons are the facilities of last resort."

More money and better access is urgently needed to kick-start the country's dilapidated network of public mental-health clinics, residential facilities, drop-in centers and substance-abuse programs. As important, because so many of the mentally ill are currently cycling through the prison system, funding and leadership must improve mental-health services within prisons.

Without such investments, U.S. prisons will increasingly replicate the insane asylums of yesteryear. And with an estimated hundred thousand mentally ill offenders being released from prison each year, communities are ill-served if those individuals are in no better (or worse) shape than they were before they entered prison.

Sasha Abramsky is a freelance journalist based in San Diego. Jamie Fellner is a program director for Human Rights Watch. They are co-authors of a Human Rights Watch report, Ill-Equipped: U.S. Prisons and Offenders with Mental Illness.