During another summer with his Aunt Petunia and Uncle Vernon, Harry Potter and Dudley are attacked by Dementors. After using magic to save Dudley and himself, Harry is expelled from Hogwarts, but the decision is later reversed after a hearing at the Ministry of Magic. Harry is whisked off by a group of wizards including Mad-Eye Moody, Remus Lupin, and several new faces, including Nymphadora Tonks and Kingsley Shacklebolt, to Number 12, Grimmauld Place, the childhood home of his godfather, Sirius Black. The building also serves as the headquarters of the Order of the Phoenix, a secret organisation founded by Albus Dumbledore, informs Harry Potter that the Ministry of Magic is oblivious to Lord Voldemort's return. At the Order's headquarters, Sirius Black, mentions that Voldemort is after an object he did not have during his previous attack.
Back at Hogwarts, Harry learns that Minister of Magic Cornelius Fudge has appointed a new Defence Against the Dark Arts professor: Dolores Umbridge. She and Harry immediately clash, and she punishes Harry for his "lies" by forcing him to write a message with a magic quill, scarring his hand. When Ron and Hermione notice Harry's scars they are outraged, but Harry refuses to go to Dumbledore, who has distanced himself from Harry 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". Umbridge recruits the Slytherin students to expose the group. Meanwhile, Harry and Cho Chang develop romantic feelings for each other.
Harry has a vision involving an attack upon Arthur Weasley, from the point of view of Arthur's attacker. Concerned that Voldemort will exploit this connection to Harry, Dumbledore instructs Severus Snape to give Harry Occlumency lessons to defend his mind from Voldemort's influence. The connection between Harry and Voldemort leads Harry to further isolate himself from his friends. Meanwhile, Bellatrix Lestrange, Sirius' deranged Death Eater cousin, escapes from Azkaban along with nine other Death Eaters. At Hogwarts, Umbridge and her Inquisitorial Squad expose Dumbledore's Army. Dumbledore escapes as Fudge orders his arrest. Umbridge becomes the new Headmistress. Harry's relationship with Cho falls apart, as he believes she betrayed Dumbledore's Army to Umbridge. Harry discovers through Snape's memories why Snape hated Harry's father James, who often ridiculed him.
Harry has another vision, this one of Sirius being tortured by Voldemort. Harry, Ron and Hermione rush to Umbridge's fireplace to alert the Order via the Floo Network, since hers is the only fireplace not being monitored, but Umbridge stops them before they can do so. As Umbridge tortures Harry, Hermione tricks Umbridge into entering the Forbidden Forest in search of Dumbledore's "secret weapon". She and Harry lead her to the hiding place of Hagrid's giant half-brother, Grawp, only to be confronted by centaurs who kidnap Umbridge after she attacks and insults 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, 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 simply a ruse to lure Harry into the Death Eaters' grasp. Harry refuses to give Lucius the prophecy, 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 unless he surrenders the prophecy.
Harry obliges just as Sirius and Remus Lupin arrive with Order members Nymphadora Tonks, Kingsley Shacklebolt and Mad-Eye Moody. As they attack the Death Eaters, Lucius drops the prophecy, destroying it. Just as Sirius overpowers Lucius, Bellatrix kills Sirius. Voldemort appears, but Dumbledore arrives through the Floo Network moments before Voldemort can kill Harry.
A duel between Voldemort and Dumbledore ensues, destroying much of the Atrium, while Bellatrix escapes. After the two prove evenly matched, Voldemort possesses Harry to try to get Dumbledore to sacrifice Harry, 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 is forced out of his position as Minister in disgrace. Umbridge is removed from Hogwarts and Dumbledore returns as headmaster. 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."