Young doctor Edward Newgate (Jim Sturgess) arrives at Stonehearst Asylum to get some clinical training but finds the eccentric superintendent Dr. Lamb (Ben Kingsley) using unusual methods that are not necessarily helpful to his psychiatric patients. Lamb also has a guard / henchman named Finn who shows signs of hostility to the newcomer.
Newgate immediately falls for one of the patients, a beautiful, well-bred woman who plays piano for the inmates. Eliza (Kate Beckinsale) is there for "hysterics", having attacked her abusive and powerful, well-connected husband who had her committed. Eliza, recognizing that Newgate is a compassionate man, begs him to flee Stonehearst but he refuses to leave without her.
Newgate hears a rhythmic banging and follows the sound to the basement, where a dozen or more people are kept in cages. They are the true staff and superintendent of the facility; Lamb was actually a patient who led a mutiny, locked up the staff and let the patients run things (including Finn). Eliza also wishes to escape but fears Lamb even more than she fears her husband.
Dr. Salt (Michael Caine), the true superintendent, was severe in some of his methods, particularly toward Lamb, so Lamb uses electroshock to erase his memories and render him an imbecile. Two men escape from the basement and try to reach the nearest village for help, but Finn kills one and the other jumps off a cliff to avoid going back.
Newgate plans to spike the drinks of the "staff", putting them to sleep while freeing real workers. Finn catches him and Lamb decides to use electroshock on him. Newgate tricks Lamb into looking at a photo that causes Lamb to suffer a complete mental breakdown; Eliza finds her courage and helps Newgate overpower Finn. They are able to free the true staff, who round up the patients and lead them back to their rooms.
TWIST: The true head nurse appears to be running things some time later, caring for the patients now including Salt and Lamb, when Eliza's husband arrives with her physician to get her released. The nurse reports that Dr. Newgate checked her out 3 weeks ago. The physician says that is impossible, that HE is Edward Newgate and the young man who stole his identity is a patient who escaped some weeks ago after seeing Eliza being presented at a medical school lecture and becoming smitten with her. They don't even know the young man's real identity because he was such a consummate liar.
The last scene shows an open-air, progressive asylum in Italy and Eliza plays the piano for the inmates. Her "husband" now goes by the name of Dr. Lamb and is apparently on staff there, and they seem quite happy.