Modern psychiatric hospitals evolved from, and eventually replaced the older lunatic asylums. The development of the modern psychiatric hospital is also the story of the rise of organized, institutional psychiatry. The moral treatment and care of the mentally ill, as opposed to isolation, was first pioneered in the Islamic world by physicians whose treatment of mental patients was regarded as a religious obligation based on the Quranic verse Do not give the property with which God has entrusted you to the insane, but feed and clothe them with this property and speak kindly to them. It greatly differed from the reigning view in which the mentally ill were viewed as under the influence of the Devil therefore needing to be isolated from society. The first psychiatric hospital was built by the Muslims in Baghdad in 705 AD, under the leadership of the Umayyad Caliph Al-Walid ibn Abd al-Malik. Others would rapidly follow, with some of the more famous ones being built in Cairo in 800 AD and in Damascus in 1270 AD. The physicians of the Islamic world would invent and use a variety of treatments, including occupational therapy, music therapy, as well as medication.
Western Europe would adopt these views later on with the advances of physicians like Philippe Pinel at the Bicêtre Hospital in France and William Tuke at the York Retreat in England. They advocated the viewing of mental illness as a disorder that required compassionate treatment that would aid in the rehabilitation of the victim. The arrival in the Western world of institutionalisation as a solution to the problem of madness was very much an event of the nineteenth century. The first public mental asylums were established in Britain; the passing of the County Asylums Act 1808 empowered magistrates to build rate-supported asylums in every county to house the many 'pauper lunatics'. Nine counties first applied, the first public asylum opening in 1812 in Nottinghamshire. In 1828, the newly appointed Commissioners in Lunacy were empowered to license and supervise private asylums. The Lunacy Act 1845 made the construction of asylums in every country compulsory with regular inspections on behalf of the Home Secretary. The Act required asylums to have written regulations and to have a resident physician.
At the beginning of the nineteenth century there were a few thousand "sick people" housed in a variety of disparate institutions throughout England, but by 1900 that figure had grown to about 100,000. This growth coincided with the growth of alienism, later known as psychiatry, as a medical specialism. The treatment of inmates in early lunatic asylums was sometimes very brutal and focused on containment and restraint.
In the late 19th and early 20th centuries, terms such as "madness," "lunacy" or "insanity"—all of which assumed a unitary psychosis—were split into numerous "mental diseases," of which catatonia, melancholia and dementia praecox (modern day schizophrenia) were the most common in psychiatric institutions.
In 1961 sociologist Erving Goffman described a theory of the "total institution" and the process by which it takes efforts to maintain predictable and regular behavior on the part of both "guard" and "captor," suggesting that many of the features of such institutions serve the ritual function of ensuring that both classes of people know their function and social role, in other words of "institutionalizing" them. Asylums was a key text in the development of deinstitutionalization.
With successive waves of reform, and the introduction of effective evidence-based treatments, modern psychiatric hospitals provide a primary emphasis on treatment, and attempt where possible to help patients control their own lives in the outside world, with the use of a combination of psychiatric drugs and psychotherapy. These treatments can be involuntary. Involuntary treatments are among the many psychiatric practices which are questioned by the mental patient liberation movement. Most psychiatric hospitals now restrict internet access and any device that can take photos. In the U.S. state of Connecticut, involuntary patients must be examined annually by a court-appointed psychiatrist. Patients may also apply for release at any time and receive a full hearing on the application.