The film opens with a birthday party for Claire (Haley Lu Richardson). Her classmate Casey (Anya Taylor-Joy) was invited out of pity, as Claire tells her father (Neal Huff) that Casey frequently gets into trouble with teachers and gets sent to detention. Casey calls for a ride home but is told the car broke down. She's about to take the bus, but Claire's dad insists that she go home with them.
The girls leave along with another friend, Marcia (Jessica Sula). Claire's dad is approached by an unseen person. Moments later, the person, a man named Kevin (James McAvoy), gets into the car. Claire thinks he just got in the wrong car by mistake, but Kevin puts on a face mask and sprays the girls with some kind of toxin that knocks them out. Casey slowly attempts to open the door to get out, but Kevin gets her too.
Kevin brings the girls into a windowless room in an unknown location. He pulls Marcia out and takes her outside. After a brief moment, Marcia runs back into the room after she peed herself. She tells the others that Kevin wanted her to dance for him. Claire says they need to fight back together to get out. Casey is calm and says they need to find out what they are there for before they make any sort of move.
We see a flashback in which a 5-year-old Casey (here played by Izzie Leigh Coffey) is with her father (Sebastian Arcelus) and her Uncle John (Brad William Henke). They are both hunters, and they teach Casey how to hunt. Uncle John talks about hunting a deer but being distracted by the buck.
A therapist, Dr. Karen Fletcher (Betty Buckley), is watching a news report on the three missing girls and how Claire's father woke up to find the girls and his car gone. Karen then receives an email from someone named Barry, saying they need to speak and it is urgent.
Barry is really one of Kevin's multiple personalities. This "alter" is a sketch artist with a heavy Boston accent. He meets with Karen regularly in this persona.
The girls continue to try to find a way out. They look through a crack in the door and see what appears to be a woman talking to their captor. Claire and Marcia call to the woman for help. She approaches the door, but it is just Kevin wearing a skirt and high heels. This alter is known as Patricia, a polite British woman. Patricia assures the girls that their captor knows why they are there and that he is not allowed to touch them.
Karen is in a conference via Skype in which she discusses her patients, most of whom are suffering from DID (dissociative identity disorder), including Kevin. Karen talks about how some identities have capabilities that the other identities may not possess, as well as the way she can sense who has come to "the light" (which alter is in control). She adds that people with DID can change their body chemistry with their thoughts.
The girls meet another identity, Hedwig, who has the mannerisms of a 9-year-old boy. He claims that Patricia and Dennis (the persona that captured the girls) are mad at him and that he is in trouble. Casey talks to Hedwig in an attempt to get a way out of there by telling him that Patricia and Dennis are still mad at him and that he's in trouble. Hedwig leaves, and the girls start looking for a way out through the walls. Claire finds a hollow spot in the ceiling and starts breaking off the plaster. Hedwig starts to come back, but Casey and Marcia hold the door back as Claire tries climbing out. Kevin reverts to Dennis as Claire starts crawling through the vents. She finds an exit and starts running for help. She hides in a locker but her trembling breath is so loud that Dennis finds her. He orders Claire to take off her shirt because it's dirty. He then locks her in a room by herself.
In another session with Karen, Kevin returns as Barry. Karen doesn't believe she is really talking to Barry. She has noticed certain characteristics that Barry is displaying normally seen with other alters like Dennis, such as OCD. Barry insists that he's gotten better. Karen mentions that Kevin has 23 distinct identities. Kevin then becomes Dennis as Karen mentions a 24th identity, "The Beast", whom Dennis says is indeed real.
Patricia brings Casey and Marcia out for some food. Marcia is forced to remove her skirt and Casey takes off her flannel shirt. Patricia brings the girls into a dining room and starts to make another sandwich. He becomes upset when he accidentally cuts the sandwich crookedly, so he starts making another one. Marcia seizes the opportunity to take a chair and strike Patricia in the back with it. She runs out for help, and Casey tries to run too, but Patricia catches her and orders her to go to her room. Marcia is eventually caught as well and is locked in a room by herself.
Karen and her assistant Jai (M. Night Shyamalan) review security footage of outside the building. A trash bin is knocked over with garbage spilled everywhere. One couple walks around it, but Dennis walks right through it, which is something Karen believes is deliberate.
Hedwig talks to Casey playfully. He asks to kiss her, and she allows him to, though it is awkward. Hedwig mentions his music collection and how he likes to dance to some Kanye West. Casey asks him to show her his room and his music collection. He takes her there, and she mentions a window that's next to his music. It's just a drawing of a closed window over another drawing of an open window. Hedwig starts to realize that Casey is trying to escape. She becomes frightened and attempts to placate him. He pulls out a walkie-talkie, which Casey uses to start calling for help while fighting off Hedwig. Hedwig subdues Casey and takes the walkie back.
We see another flashback with Little Casey on a hunting trip. With her dad not around, Uncle John starts wanting to "play". He strips down to his underwear and tells Casey to take off her clothes because "animals don't wear clothes". Later, John emerges from behind a rock and sees Casey holding a rifle at him. He manages to take it back from her so that she doesn't pul the trigger.
Claire and Marcia attempt to escape using a wire to unlock the door from the outside Marcia's room. They are unsuccessful.
Karen goes to Kevin's home and is greeted by Dennis. He invites her inside and they continue to discuss The Beast, as well as "The Horde", which is the name given for the major identities that control Kevin (Dennis, Barry, Patricia, and Hedwig). Karen then becomes genuinely terrified. She goes outside and finds Claire trapped in her room, but Dennis pulls Karen away before she can help.
Casey finds a laptop with videos on every one of Kevin's identities. She sees one called Orwell, who discusses philosophy, and another named Jade, who is diabetic.
Dennis goes to an abandoned train car and starts to transform into The Beast. He is significantly taller and stronger than any other identity. He returns home and finds Karen writing something on a piece of paper. She grabs a small knife as he crawls on the wall and grabs her. Karen starts trying to stab him, but the knife breaks. The Beast then squeezes Karen until her spine snaps and she dies.
Casey gets out and tries to find the other girls. She finds Marcia dead with her stomach having been ripped open. Casey then finds Claire alive, but she gets dragged as The Beast starts attacking her. Casey finds the paper that Karen wrote on. It says "Say his name - Kevin Wendell Crumb". The Beast finds Casey, but she repeatedly shouts his name, making him revert to normal. We briefly see a flashback of Kevin's mother yelling at him as a child by saying his full name and telling him he's made a mess. Present Day Kevin has no memory of what he's done as Casey tells him he killed Karen, Claire, and Marcia. He tells Casey there's a gun in one of the cabinets, and that she must kill him. The major identities start to take control all at once. Casey runs as The Beast starts to come back.
Casey finds some shells and loads them into the gun. The Beast starts crawling up on the ceiling and starts taking out the lights, leaving Casey with no sight to shoot at him. The Beast attacks Casey, ripping her shirt and biting her leg, but she gets away. She closes herself in a cage and loads the gun with more shells. The Beast starts bending the bars to get in, but he then notices multiple scars on Casey's body. Another flashback shows Little Casey after her father's funeral, and John telling her he will be her new guardian. The Beast then proclaims that Casey is pure-hearted, and he leaves her alone.
Not long after, a man goes downstairs and finds Casey. He carries her outside to safety. She looks around on the outside and sees many animals in an enclosure. Medics arrive and take Casey in.
Kevin is somewhere by himself, with The Horde controlling him completely now. Patricia says that The Beast will protect them now.
The last scene is in a diner where people are watching a news report on what Kevin did. The anchorwoman mentions how The Beast identity displays characteristics of the animals in the enclosure where he worked. A patron mentions that the case is similar to a man in a wheelchair from 15 years earlier. When she can't remember his name, someone next to her replies, "Mr. Glass". We see that it is David Dunn (Bruce Willis; his character from "Unbreakable" in a surprise cameo). Fade out.