The need for more and better mental health services is a common refrain after violent tragedies, such as the mass shooting last month in Newtown, Conn., or recent instances of subway passengers pushed onto the tracks in New York City.

As service providers grapple with limited resources, though, judges point to the growing number of mental health courts — programs that offer mentally ill criminal defendants treatment-based alternatives to jail — as a success story. An offshoot of the popular drug courts, mental health courts were the product of judges, prison officials, lawyers and mental health advocates frustrated with the lack of options for mentally ill defendants.