Volunteers arrive for a psychological study led by Dr. Archaleta (Stevens) in which participants will be divided into groups acting as prison guards and inmates. Among them is Travis (Brody), a proud anti-war protestor, and Michael Barris (Whitaker), a 42-year-old man who still lives with his domineering mother. After interviews measuring responses to various scenes of violence are conducted, a chosen 26 are driven to an isolated building set up as a prison and split into six guards and 20 prisoners. Travis is assigned to be a prisoner, Barris to be a guard. Basic rules are outlined: prisoners must eat, and fully consume, three meals a day; there will be 30 minutes of rec daily; prisoners must remain within designated areas. The guards in turn must ensure prisoners obey the rules, and deal with transgressions commensurately within 30 minutes. Archaleta stresses that the experiment will end immediately at the first sign of violence or quitting. If they manage to follow the rules for two weeks, each man will be paid $14,000.

Travis shares his cell with Benjy, a graphic novelist, and Nix, a member of the Aryan Brotherhood. Barris, concerned that some of the guards, particularly Chase, may be capable of violence, tries to dissuade them from aggressive behavior. Instead, the guards grow more forceful in order to make prisoners follow the rules. Barris becomes more and more sadistic. Despite increasing abuse from the guards, Travis remains defiant. Realizing Travis is influencing prisoner dissent, Barris decides to humiliate him, as physical retribution is forbidden. Under Barris’ lead Travis is abducted, head shaved, and urinated upon. The red light does not come on, and Barris takes this as a sign that his actions were “commensurate”. He reassures the guards that they are behaving appropriately. When fellow guard Bosch dissents, Barris pressures him by reminding that quitting early will forfeit payment.

Travis discovers that Benjy, who is taken ill, had concealed his diabetes, thinking that he could manage the condition himself. When Travis pleads for Bosche to intervene, Bosche tries to help by locating Benjy’s insulin, but is caught by other guards. Barris, to Travis’ surprise, gives Benjy his insulin, but later takes revenge by massing all other guards to beat Bosche severely, who is then left among the prison population. Barris also orders Travis to clean the prison toilets as punishment for his defiant attitude and his attempt to help Benjy. Travis taunts Barris, saying he should use his $14,000 for psychological treatment. The guards respond by shoving Travis’ head into the toilet, nearly drowning him.

One morning while being humiliated during roll call, Travis removes his prison shirt as a sign that the experiment should end, and is followed by the other prisoners. Travis jumps up to one of the cameras and demands that the group be let go, but is dragged to the floor by the guards, who choke him with their batons. When Benjy tries to defend Travis, Barris hits Benjy hard on the head with his baton, leaving him twitching on the floor. Guards throw Travis into an old boiler pipe overnight, attack remaining prisoners, and chain them up across the compound.

While locked in the dark boiler, Travis realizes that there is a hidden infrared camera watching him, even there, and as his despondence turns to anger he manages to get out. He interrupts the rape of a prisoner by Chase, knocks him out, and sets the other prisoners free. Upon finding Benjy chained up and left to die, Travis leads an assault against the guards, chasing them through the building. Even as the rest of the guards try to lift the shutters to escape, Barris tries to keep them in. The money is no longer his main concern; instead he is unwilling to let go of his power. A vicious brawl ensues with the prisoners largely overwhelming the guards in sheer numbers. Barris, blaming Travis for causing the unrest, attempts to stab him, but the latter catches the blade with his hand. Barris abruptly pulls away, shocked at his actions before he is tackled to the ground. Travis proceeds to brutally beat Barris, as the siren finally blares. The red light comes on and the doors open, signaling the end of the experiment.

The group emerges into bright sunshine and sit in stunned silence on the grass until a bus arrives. They are shown being driven home on the bus; clean, dressed, and paid for their participation in the experiment. Travis and Barris share a silent glance as Barris stares down at his $14,000 check. Nix asks Travis if he still believes that humans are higher in the chain of evolution than monkeys. Travis responds that he does, because people have the ability to change. Audio news snippets suggest that Archaleta is being tried for manslaughter. Travis meets his girlfriend in India. She notices that his knuckles are bruised, in contrast to the beginning of the film, when she noted his pristine knuckles, an indication that he was, at the time, incapable of violence.