After burying Dobby, Harry Potter asks the goblin Griphook to help Ron Weasley, Hermione Granger and him break into Bellatrix Lestrange’s vault at Gringotts bank, suspecting a Horcrux may be there. Griphook agrees in exchange for the Sword of Gryffindor. Wandmaker Ollivander tells Harry that two wands taken from Malfoy Manor belonged to Bellatrix and Draco Malfoy, though Malfoy’s has changed its allegiance to Harry.
In the 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 security. The three release the dragon guardian and flee on its back. Harry sees a vision of Lord Voldemort killing goblins including Griphook, and learns Voldemort is aware of the theft. Harry also realises there is a Horcrux at Hogwarts somehow connected to Rowena Ravenclaw. The trio apparate into Hogsmeade, where Aberforth Dumbledore reluctantly instructs the portrait of his deceased younger sister Ariana to fetch Neville Longbottom, who leads the trio through a secret passageway into Hogwarts.
Severus Snape hears of Harry’s return and warns staff and students of punishment for aiding Harry. Harry confronts Snape, who flees after Minerva McGonagall challenges him to a duel. Voldemort then arrives with the Death Eaters, demanding Harry is given over to him; McGonagall gathers the Hogwarts community 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, located in the Room of Requirement. In the Chamber of Secrets, Hermione destroys the Horcrux cup with a Basilisk fang. In the Room of Requirement, Draco, Blaise Zabini and Gregory Goyle attack Harry, but Ron and Hermione intervene. Goyle casts a Fiendfyre curse; unable to control it, he is burned to death while Harry and his friends save Malfoy and Zabini. Harry stabs the diadem with the Basilisk fang, and Ron kicks it into the Room of Requirement to be destroyed. As Voldemort’s army attacks, Harry, seeing into Voldemort’s mind, realises that Voldemort’s snake Nagini is the final Horcrux. After entering the boathouse, the trio witness Voldemort telling Snape that the Elder Wand cannot serve Voldemort until Snape dies; he then orders Nagini to kill Snape. Before dying, Snape tells Harry to take his memories to the Pensieve. Meanwhile, Fred Weasley, Remus Lupin, and Nymphadora Tonks are killed in the chaos at Hogwarts.
Harry learns from Snape’s memories that while Snape despised Harry’s late father James, who bullied him, he loved his late mother Lily. Following her death, Snape worked with Albus Dumbledore to protect Harry from Voldemort due to his love for Lily. Harry also learns that Dumbledore was dying and wished for Snape to kill him, and that the Patronus doe he saw in the woods that led him to the sword was conjured by Snape. Harry discovers that he himself became a Horcrux when Voldemort originally failed to kill him; he must die to destroy the piece of Voldemort’s soul within himself. Harry surrenders himself to Voldemort in the Forbidden Forest. Voldemort casts the Killing Curse upon Harry, who finds himself in limbo. Dumbledore’s spirit meets him and explains that the part of Voldemort within Harry was killed by Voldemort’s curse. Harry returns to his body, determined to defeat Voldemort.
Voldemort announces Harry’s apparent death to everyone at Hogwarts and demands their surrender. As Neville gives a defiant response and draws the sword from the Sorting Hat, Harry reveals he is still alive; the Malfoys and many Death Eaters abandon Voldemort. While Harry confronts Voldemort in a duel throughout the castle, Molly Weasley kills Bellatrix in the Great Hall and Neville decapitates Nagini, making Voldemort mortal. Harry and Voldemort’s fight ends with Voldemort’s own Killing Curse rebounding and obliterating him. After the battle, Harry explains to Ron and Hermione that the Elder Wand recognised him as its true master after he disarmed Draco, who had earlier disarmed its previous owner, Dumbledore. Harry destroys the Elder Wand rather than claim it.
Nineteen years later, Harry and Ginny Weasley, Ron and Hermione, and Draco proudly watch their children leave for Hogwarts at King’s Cross station.