Upon arrival at Hogwarts, Harry learns that Minister for Magic Cornelius Fudge has appointed a new Defence Against the Dark Arts professor: Dolores Umbridge, a senior Ministry official who refuses to teach practical magic due to her belief that Dumbledore is forming a rebellion against the Ministry. Umbridge and Harry immediately clash, as she is oblivious to Voldemort's return and tortures Harry by writing on the skin on the back of his hand through a cursed quill. When Ron and Hermione notice these scars, they are outraged but Harry refuses to go to Dumbledore as he has distanced himself from him since the summer. As Umbridge's control over the school increases, Ron and Hermione aid Harry in forming a secret group to train students in defensive spells, calling themselves "Dumbledore's Army". The Slytherin students are recruited by Umbridge to expose the group. Meanwhile, Harry and Cho Chang develop romantic feelings for each other and begin a relationship during Christmas, Cho being Harry's first kiss at the last DA meeting before the holidays. However, Harry discovers that his behaviour is becoming erratic and possibly more similar to Voldemort's.
Harry has a vision involving an attack upon Arthur Weasley in the Department of Mysteries, from the point of view of Arthur's attacker. Concerned that Voldemort will exploit his connection to Harry, Dumbledore instructs Professor Snape to give Harry Occlumency lessons to block his mind from Voldemort's influence. These lessons increase Harry's psychological problems, as he is forced to relive everything bad that has ever happened to him. During one lesson, Harry got annoyed at what he saw and requested a break but Snape refused and forced Harry to continue the lesson. This only got the spell reversed on him by Harry where Harry sees the Vision on why Snape hates his father, James, who often had bullied him. The connection between Harry and Voldemort leads Harry to isolate himself from everyone, and he pushes not only Ron and Hermione but Ginny, Neville, the Weasley twins and Luna away, as he feels "so angry all the time". Bellatrix Lestrange, Sirius' deranged cousin, escapes from Azkaban along with nine other Death Eaters. At Hogwarts, Umbridge and her Inquisitorial Squad uncover Dumbledore's Army after illegally interrogating Cho with Veritaserum. Dumbledore covers up for Harry, but escapes as Fudge orders his arrest. With Dumbledore gone, Umbridge becomes the new Headmistress. Harry's relationship with Cho falls apart, mostly due to Cho having betrayed Dumbledore's Army to Umbridge (unknown to Harry, however, is that Cho was under the influence of Veritaserum, a truth potion).
During an O.W.L. exam, the Weasley twins revolt and set off fireworks in the Great Hall, causing chaos for Umbridge. During this event, Harry has a vision of Sirius being tortured by Voldemort within the Department of Mysteries. Harry, Ron and Hermione rush to Umbridge's fireplace to alert the Order via the Floo Network, since it is the only one not being monitored, but Umbridge stops them before they can do so. When she threatens to use the Cruciatus Curse to get information out of Harry about the trio's intentions, Hermione tricks Umbridge into entering the Forbidden Forest in search for Dumbledore's "secret weapon". She and Harry lead her to the hiding place of Hagrid's half-giant brother, Grawp, only to be confronted by centaurs who kidnap Umbridge after she attacks them. Harry, Hermione, Ron, Luna, Neville and Ginny fly to the Ministry of Magic on Thestrals in an attempt to save Sirius.
The six enter the Department of Mysteries where they uncover a bottled prophecy involving Harry and Voldemort, the object Voldemort was after. However, they are ambushed by Death Eaters including Lucius Malfoy and Bellatrix Lestrange. Lucius reveals that Harry only saw a dream of Sirius being tortured; it was not an actual situation, rather a method to lure Harry into the Death Eater's grasp. Lucius attempts to persuade Harry to give him the prophecy, telling him it will reveal why Voldemort could not kill Harry when he was an infant. Harry refuses and a fight between Dumbledore's Army and the Death Eaters ensues. The Death Eaters take everyone except Harry as hostages, threatening to kill them if he does not surrender the prophecy. Harry obliges just as Sirius and Remus Lupin arrive with Order members Nymphadora Tonks, Kingsley Shacklebolt and Mad-Eye Moody. They attack the Death Eaters and Lucius drops the prophecy, destroying it. Harry and Sirius duel him. Just as Sirius defeats Lucius, Bellatrix kills Sirius. Despite Remus trying to hold him back, Harry goes after Bellatrix, who runs away continuously saying "I killed Sirius Black" in a song-like manner. Harry chases and corners Bellatrix in the Atrium and attempts to perform the Cruciatus Curse on her, but to little avail (it knocks her down). Voldemort appears, but Dumbledore arrives through the Floo Network moments before Voldemort can kill Harry.
A duel between Voldemort and Dumbledore ensues while Bellatrix escapes. After the two prove evenly matched, Voldemort possesses Harry in order to try to get Dumbledore to sacrifice Harry in the hope of killing him, but the love Harry feels for his friends and Sirius makes it impossible for Voldemort to remain in his body. Ministry officials arrive before Voldemort disapparates; Fudge is forced to admit that Voldemort has returned and resigns as Minister. Dumbledore returns as headmaster of Hogwarts after he and Harry are vindicated. Dumbledore explains that he distanced himself from Harry throughout the year hoping it would lessen the risk of Voldemort using their connection. Harry comes to terms with the prophecy; "Neither can live while the other survives." As Harry and his friends head towards the Hogwarts Express, Harry tells his friends that even though a war is beginning, unlike Voldemort, they have something worth fighting for.