As Lord Voldemort retrieves the Elder Wand from Albus Dumbledore's grave, Severus Snape has become Hogwarts headmaster. After burying Dobby, Harry Potter has the goblin Griphook help him, Ron, and Hermione break into Bellatrix Lestrange's vault at Gringotts bank, suspecting a Horcrux may be there. Griphook agrees, in exchange for the Sword of Gryffindor. Harry has wandmaker Ollivander identify two wands taken from Malfoy Manor. Ollivander says they belonged to Bellatrix and to Draco Malfoy, but Malfoy's has changed its allegiance to Harry.In Bellatrix's vault, Harry discovers the Horcrux is Helga Hufflepuff's cup. He retrieves it, but Griphook snatches the sword and abandons the trio, leaving them cornered by the alerted security. The three release the dragon guardian and flee on its back. Harry sees a vision of Voldemort killing goblins, including Griphook, and learns Voldemort is aware of the theft. Harry also realizes there is a Horcrux at Hogwarts somehow connected to Rowena Ravenclaw. The trio apparate into Hogsmeade, and set off Caterwauling alarms. They are rescued by Aberforth Dumbledore, who instructs the portrait of his younger sister, Ariana, to fetch Neville Longbottom, who leads the trio through a secret passageway into Hogwarts.
Snape hears of Harry's return and warns staff and students of the severe punishment for aiding Harry. Harry confronts Snape, who flees after Minerva McGonagall challenges him to a duel. McGonagall gathers the community of Hogwarts to prepare for battle. At Luna Lovegood's insistence, Harry speaks to Helena Ravenclaw's ghost, who reveals that Voldemort performed "dark magic" on her mother's diadem, which is in the Room of Requirement. Ron and Hermione go to the Chamber of Secrets, where Hermione destroys the Horcrux cup with a Basilisk fang. In the Room of Requirement, Draco, Gregory Goyle and Blaise Zabini attack Harry, but Ron and Hermione intervene. Goyle casts a Fiendfyre curse and unable to control it, is burned to death while Harry and friends save Malfoy and Zabini. Harry stabs the diadem with the Basilisk fang and Ron kicks it into the Room of Requirement, where it is destroyed. As Voldemort's forces attack the school, Harry, seeing into Voldemort's mind, realizes that Voldemort's snake Nagini is the final Horcrux. After entering the boathouse, the trio witness Voldemort telling Snape the Elder Wand cannot serve him until Snape dies; he then has Nagini kill Snape. Before dying, Snape tells Harry to take his memories to the Pensieve. In the chaos at Hogwarts, Fred, Remus, and Tonks are killed.
Harry learns from Snape's memories that Snape loved Harry's mother, Lily, but despised his father, James, the latter having bullied him. Following her death, Snape worked secretly with Dumbledore to protect Harry from Voldemort because of his love for Lily. Harry also learns that Dumbledore's death at Snape's hands was planned between them. Harry discovers that he became a Horcrux when Voldemort originally failed to kill him and that Harry must die to destroy the piece of Voldemort's soul within him. Harry goes to die at the hands of Voldemort in the Forbidden Forest. Voldemort casts the Killing Curse upon Harry, who finds himself in a limbo where Dumbledore's spirit meets him and explains that the part of Voldemort within Harry was killed by Voldemort's own curse. Harry decides to return to his body to face Voldemort for the final time.
Voldemort announces Harry's apparent death to everyone at Hogwarts, and that anyone who defies him will be killed. As Neville gives a defiant speech, Harry reveals he is alive. Neville draws the Sword of Gryffindor from the Sorting Hat, and as Harry engages Voldemort in a duel throughout the castle, Neville decapitates Nagini, leaving Voldemort mortal. Molly Weasley kills Bellatrix in the Great Hall. The final stand of Harry and Voldemort's fight is Voldemort's own Killing Curse rebounding and obliterating him. After the battle, Harry explains that the Elder Wand had recognized him as its master because he had disarmed Draco at Malfoy Manor, who in turn had disarmed its previous owner, Dumbledore. Harry snaps the Elder Wand, rejecting its power.
Nineteen years later, Harry and Ginny Potter, with Ron and Hermione Weasley, watch proudly as their children leave for Hogwarts from King's Cross station.