Maria Spencer, portrayed by Saoirse Ronan, serves as a Year 5 teacher at a primary school located in Somerset, England. Her professional life is plagued by the constant disruptions caused by one of her students, Danny (Eddie Waller), whose behavioral issues create a chaotic classroom environment. The situation reaches a breaking point when Danny pushes a fellow student, Pauline, down a flight of stairs, resulting in a broken arm for the girl and an immediate suspension for Danny.
In an effort to address the boy's behavior, Maria attempts to coordinate with Danny's father, Josh, a delivery driver. However, Josh is completely dismissive of Maria's concerns and brushes off any attempts to discuss his son's welfare or conduct. Shortly thereafter, Maria encounters Danny in a car park where he is actively vandalizing vehicles, including her own. In the heat of the confrontation, Maria intervenes, but the encounter takes a dark turn when she accidentally knocks him unconscious.
Panic sets in as Maria drives the unconscious boy to a hospital. However, upon waking, Danny threatens to report her for attacking him, ignoring her pleas that the incident was a mere accident. Overwhelmed by fear and desperation, Maria abruptly leaves the hospital with him and drives him to her own home. Once inside, Danny's destructive tendencies resurface; after he begins wreaking havoc throughout the house, Maria makes the drastic decision to lock him inside her basement.
The following morning, Maria returns to her teaching duties. With the disruptive influence of Danny gone, her classroom transforms. During an official Ofsted inspection, the students perform exceptionally well, and Maria receives significant praise for the sudden and dramatic improvement in her teaching results.
As the days pass, Maria continues to keep Danny confined in the basement. Upon discovering that the boy is completely illiterate, she begins to privately tutor him in reading and writing. To make his captivity more bearable, she furnishes the basement with video games and beanbag furniture, and provides him with new clothes. To maintain total control over him, she utilizes a harness—ironically delivered to the house by a distraught Josh—to keep him restrained.
This arrangement leads to a period of unprecedented professional success for Maria. Her class continues to thrive, and her standing at the school improves her relationship with Sam, the school's deputy headteacher and her former romantic partner.
However, the secret is threatened when Pauline, who has become increasingly attached to Maria, visits her home. Pauline discovers that Danny is being held captive in the basement, but instead of reporting the crime, she uses this knowledge as leverage to receive special treatment from Maria. The tension peaks during one visit when Pauline insults Danny, cruelly telling him that no one misses him. This triggers a violent outburst from Danny, forcing Maria to flee the room and hold the door shut until Pauline eventually exits the house.
The facade finally crumbles during a parents' evening. Pauline interrupts the event with a public performance that reveals the horrifying truth about Danny's imprisonment. While Maria breaks down and admits to the kidnapping, the reaction from the parents is unexpected. Because their own children's grades have improved and the school's atmosphere has stabilized since Danny disappeared, the parents decide not to report Maria. Instead, they begin bringing food for Danny, essentially collaborating in his captivity to ensure their children's continued academic progress.
In the aftermath, the headteacher, Sylvia, resigns due to the scandal, leading to Sam being promoted to the position of headteacher. Maria returns home and coldly informs Danny that he will never be released from the basement.
Months later, Maria is honored at a large school assembly for her perceived success as an educator. During the event, the school announces a scholarship established in honor of the still-missing Danny. However, unknown to Maria, Danny has been working tirelessly. Using nothing more than an electric toothbrush, he gradually digs through the basement wall. The film concludes with Danny finally breaking through and running freely along a road, having escaped his captor.