The story opens with Harry Potter enduring another unhappy summer at the Dursleys'. When Uncle Vernon's visiting sister, Marge, viciously abuses Harry and insults his parents, Harry loses his temper, inadvertently causing Marge to inflate and float into the air. Harry runs away and is picked up by the Knight Bus that takes him to Leaky Cauldron, but not before he glimpses a dangerous-looking creature lurking in the nearby bushes. Reaching Diagon Alley, he is met by Minister of Magic Cornelius Fudge, who surprisingly assures Harry that the matter involving Marge is resolved. While at the Leaky Cauldron, Harry overhears Mr. and Mrs. Weasley arguing over whether or not Harry should be warned about Sirius Black, a fugitive from Azkaban, the wizard prison, who may be intending to murder him.
At Hogwarts, there are two new teachers: Professor Remus Lupin for Defense Against the Dark Arts and, to Harry, Ron, and Hermione's delight, Hagrid for Care of Magical Creatures. With Black still at large, creatures called Dementors patrol the school. Dementors drain happiness from anyone nearby, and Harry is particularly vulnerable to their presence because "there are horrors in [Harry's] past that others don't have", prompting Lupin to teach him the Patronus charm to repel them.
Unable to witness the execution, Harry, Ron, and Hermione walk away towards the castle. However, Scabbers, Ron's rat, escapes from his pocket and they chase it to the Whomping Willow, an aggressive tree that attacks anyone who goes near it. Just as Ron catches Scabbers, a huge black dog appears and starts attacking Harry. Ron tries to help Harry, and the dog attacks him instead, dragging him to a tunnel under the Whomping Willow, and breaking his leg in the process. Harry and Hermione follow the dog in the hope of rescuing Ron.
The tunnel leads to the Shrieking Shack where Harry confronts Sirius Black, an Animagus who is able to transform into an animal at will. Lupin, who spotted the group on the Marauder's Map, suddenly bursts in and embraces his old friend Black. Confronted by Hermione, Lupin admits to being a werewolf and the Map's creator, along with Black, Pettigrew, and James Potter, the latter two also being illegal Animagi (a rat and a stag, respectively). Lupin and Black explain that Scabbers is actually Peter Pettigrew in his Animagus form. Pettigrew is Voldemort's servant, and it was he who betrayed the Potters, framing Black for the crimes. Black escaped Azkaban seeking revenge. Harry halts Black and Lupin from executing Pettigrew, preventing his father's two best friends from becoming killers.
As they escort Pettigrew back to the castle, Black invites Harry to stay with him, allowing Harry to leave the Dursleys forever. However, this hope is quickly dashed as the full moon rises and Lupin transforms into a werewolf. During the ensuing commotion, Pettigrew escapes in his animagus rat form while Black transforms into a dog to protect the others from Lupin, who eventually runs off. Black is badly injured, however, and as Dementors move in to attack him, Harry sees a mysterious figure in the distance who casts a powerful, stag-shaped Patronus, scattering the vicious creatures. Before passing out, Harry becomes convinced it was his late father who produced the Patronus.
In the hospital wing, Harry learns that he and Hermione have to go back in time using Hermione's Time Turner. They go to the time when Buckbeak is being executed, and lure him out of Hagrid's hut. After freeing Buckbeak, Harry and Hermione head back to the Whomping Willow. But Harry, who realized that Lupin could be headed there suggested that they go to Hagrid's Hut. After going to Hagrid's Hut, Harry, against Hermione's wishes, hurries down to the lake to save Sirius. Dementors swarm and then Harry that went back in time conjured the stag Patronus and finds out that it wasn't his father conjuring it, it was himself! After saving and releasing Sirius from Azkaban, they give Buckbeak to Sirius so he won't be discovered.
Harry and Hermione later inform Ron what occurred earlier that day. The trio runs into Hagrid, who says that Lupin resigned. Harry went to stop him, but Lupin just returned the Map to Harry, and left. Then, after a few comforting words from Albus Dumbledore, Harry left school, on the train, where Sirius sent Ron an owl called Pigwidgeon. Later, at King's Cross Station, Harry scared the Dursleys by saying that he was in contact with a full-grown wizard that they thought was an evil convict.