Spoilers through Harry Potter and the Deathly Hallows Part 2.
Harry Potter (Daniel Radcliffe) is the master of the Elder Wand by the final battle. Draco Malfoy (Tom Felton) won its allegiance when he disarmed Albus Dumbledore (Michael Gambon) on the Astronomy Tower, and Harry won it from Draco at Malfoy Manor. Severus Snape (Alan Rickman) never owned it, so when Lord Voldemort (Ralph Fiennes) kills him for it, he kills him for nothing.
Neither boy sets out to win it.
Draco wins the wand on the tower
Harry Potter and the Half-Blood Prince
Draco gets there first. He shouts “Expelliarmus!”, Dumbledore’s wand flies out of his hand, and then Draco cannot bring himself to do anything more with the advantage.
Snape arrives a few minutes later and kills Dumbledore. By then the wand has already changed sides. Its loyalty went to Draco the moment it left Dumbledore’s hand.
Harry wins Draco’s wand at Malfoy Manor
Harry Potter and the Deathly Hallows Part 1
Ollivander holds a wand opposite Harry while Hermione and Ron stand behind Harry. Warner Bros. Pictures
Harry disarms Draco in the fight at Malfoy Manor and gets away with his wand. The Elder Wand is nowhere near the room, and it does not need to be. Beating its master is enough to move its loyalty, and when Harry beats Draco, Draco is the Elder Wand’s master.
At Shell Cottage, early in Part 2, the wandmaker Ollivander (John Hurt) identifies it as “the wand of Draco Malfoy”, and Harry asks, “Was? Is it not still?”
Ollivander’s answer is the rule: “Well, perhaps not, if you won it from him. I sense its allegiance has changed.”
Voldemort kills Snape for a wand Snape never owned
Harry Potter and the Deathly Hallows Part 2
Voldemort raises the Elder Wand above his head. Warner Bros. Pictures
Voldemort took the Elder Wand from Dumbledore’s tomb at the end of Part 1, and it is not working properly for him. In the boathouse he tells Snape why: “The Elder Wand belongs to the wizard who killed its last owner.” Snape killed Dumbledore, and “While you live, the Elder Wand cannot truly be mine.” Then he cuts Snape’s throat with it and orders, “Nagini, kill.”
It feels odd. Voldemort has just explained that the wand belongs to Snape, and it cuts Snape’s throat without any trouble.
The ending answers it. Voldemort has the rule wrong: the wand goes to whoever beats its master, killing or not, and Draco beat Dumbledore before Snape arrived. Voldemort kills the wrong man for the wrong reason, with a wand that never answered to Snape in the first place.
Harry explains it on the viaduct
Harry Potter and the Deathly Hallows Part 2
After the battle, Hermione Granger (Emma Watson) asks the question the duel leaves behind: “Why didn’t it work for him? The Elder Wand?” Harry’s answer starts with “It answered to somebody else.”
“It was Draco who disarmed Dumbledore that night in the Astronomy Tower,” he tells her and Ron Weasley (Rupert Grint), and the wand answered Draco “until the other night when I disarmed Draco at Malfoy Manor.” Ron gets as far as “So that means...” and Harry finishes it for him: “It’s mine.”
Voldemort’s stolen wand has been loyal to Harry for the whole of their last duel.
Harry breaks the wand Voldemort killed for
Harry Potter and the Deathly Hallows Part 2
Ron asks what they should do with it. Hermione’s reply is one word, “We?”, and Ron presses on: “that’s the Elder Wand, the most powerful wand in the world.”
Harry snaps it in two and throws the pieces off the viaduct. He destroys the thing Voldemort killed Snape to own.
Two disarmings decide who owns the Elder Wand, and neither looked important at the time. Snape dies for a rule Voldemort got wrong, and Harry ends the whole contest by snapping the wand in half.