As the group heads back to the castle, Sirius Black asks Harry to come live with him, as he is Harry's guardian, permitting Harry to escape his uncle's home forever. However, the full moon rises, causing Lupin to turn into a werewolf. During the ensuing commotion, Pettigrew escapes. Black turns into his dog form to protect the others from Werewolf Lupin. Lupin flees, leaving Black badly injured. As Dementors move in to attack Black, Harry sees a mysterious figure in the distance cast a powerful stag-shaped Patronus, scattering the vicious creatures. Harry becomes convinced it is his father, or at least his father's spirit, who produced the Patronus. Black is then captured and taken to the castle where the Dementors intend to suck out his soul.
Hermione reveals to Harry that she was entrusted with a time-travelling device called a Time-Turner, which is how she was able to attend so many classes. Prompted by Dumbledore, she and Harry travel three hours into the past, watching themselves go through the night's previous events. They set Buckbeak free and return to the Whomping Willow. As the Dementors are about to attack the "other" Harry and Black, Harry realizes that the mysterious figure he saw earlier was actually himself. Armed with the new memory of his talk with Black, he casts the powerful Patronus that repels the Dementors. Harry and Hermione free Black, who escapes on Buckbeak as the two return to Dumbledore and resume their normal timeline.
Remus Lupin resigns as an angry Severus Snape, who has a childhood grudge against the Marauders, tells the whole of Slytherin House that Lupin is a werewolf. After Harry says good-bye to Lupin, Dumbledore tells Harry that Pettigrew is now in his debt, a fact for which he may one day be grateful. He also tells Harry that "all four Marauders were on school grounds tonight" and says that James Potter lives in Harry.