Harry Potter and the Order of the Phoenix follows the titular hero, Harry, through his fifth year at Hogwarts School of Witchcraft and Wizardry. Harry forms a new familial bond with his godfather, the fugitive Sirius Black, and experiences troubling visions of his archenemy Voldemort. The story follows Harry's attempt to make sense of his visions while struggling with self-doubt, his lack of a family, and growing anxiety due to his apparent connection to Voldemort's mind.
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 rescinded. Harry is whisked off by a group of wizards to Number 12, Grimmauld Place, the home of his godfather, Sirius Black. The house also serves as the headquarters of the Order of the Phoenix, of which Mr. and Mrs. Weasley, Remus Lupin, Mad-Eye Moody, and Sirius are members. Ron Weasley and Hermione Granger explain that the Order of the Phoenix is a secret organisation led by Hogwarts headmaster Albus Dumbledore, dedicated to fighting Lord Voldemort and his followers, the Death Eaters. From the members of the Order, Harry and the others learn that Voldemort is seeking an object that he did not have prior to his first defeat, and assume this object to be a weapon of some sort. Harry learns that the Ministry of Magic, led by Cornelius Fudge, is refusing to acknowledge Voldemort's return because of the trouble that doing so would cause, and has been running a smear campaign against him and Dumbledore.
At Hogwarts, Harry learns that Dolores Umbridge, a senior employee under the Minister of Magic, Cornelius Fudge, will be the new Defence Against the Dark Arts teacher. Umbridge and Harry clash, as she, like Fudge, refuses to believe that Voldemort has returned. She punishes Harry for his rebellious outbursts by having him write "I must not tell lies" with a cursed quill that carves the phrase into his skin. She also refuses to teach her students how to perform defensive spells, prompting Harry, Ron and Hermione to form their own Defence Against the Dark Arts group (with students from Gryffindor, Ravenclaw and Hufflepuff), which they call Dumbledore's Army. Many students sign up, including Neville Longbottom, Fred and George Weasley, Ginny Weasley and Luna Lovegood. The club meets in the Room of Requirement to learn and practise Defence spells under Harry's instruction.
Meanwhile, Rubeus Hagrid has not yet returned from the secret mission given to him by Dumbledore at the end of the previous book, and is absent for the first part of the school year. Upon his return, Harry, Ron, and Hermione learn that his mission, which was mostly unsuccessful, was to seek out the last giants to stop them from joining Lord Voldemort. Dolores Umbridge has been steadily amassing more and more power and influence at the school, and as she begins regularly inspecting Hagrid's Care of Magical Creatures lessons, it is clear that she intends to get rid of him.
One night, Harry has a vision through the eyes of Voldemort's snake Nagini, possessed by Voldemort, attacking Ron's father Arthur Weasley. Harry informs Professor McGonagall and Dumbledore, and Mr. Weasley is rescued. Dumbledore arranges for Harry to take Occlumency lessons with Professor Snape to protect his mind against further invasions by Voldemort.
Umbridge finally sacks Professor Trelawney, the Divination teacher; However, she is outraged when Professor Dumbledore undermines her power by allowing Trelawney to continue living at the school, and hires Firenze, a centaur, to take her place, in spite of Umbridge's prejudice against part-humans. Soon after, Umbridge is given a tip-off about Dumbledore's Army by Marietta Edgecomb, who in doing so unwittingly activates a curse set by Hermione which disfigures her face. When Dumbledore takes responsibility for the illegal organisation, he is forced to leave the school and go into hiding. Dolores Umbridge becomes headmistress, and Fred and George cause pandemonium around the school in revenge.
During one Occlumency lesson, Snape is called away and Harry, left alone, looks into Snape's pensieve, viewing a memory of his time as a student at Hogwarts. Harry sees his father, James Potter, and Sirius bullying Snape. Snape catches Harry and, enraged, refuses to continue the lessons. Distraught, Harry talks to Sirius and Lupin by using Floo powder through the fireplace in Umbridge's own office, under cover of a distraction by Fred and George. The twins then leave Hogwarts to start a joke-shop in Diagon Alley.
Suspecting that he will be next teacher to be sacked by Umbridge, Hagrid confesses to Harry, Ron and Hermione that he has brought his giant half-brother, Grawp, to Hogwarts, and hidden him in the Forbidden Forest, with the intention of eventually introducing him to human society. Hagrid asks the three of them to look after Grawp if he himself must leave the school. Sure enough, Umbridge leads a party of Aurors to attack Hagrid in his house one night. Hagrid overpowers them and flees the school; McGonagall, trying to disrupt the violence, is badly injured and is put in St. Mungo's Hospital.
On the last day of OWL tests, Harry has a vision of Sirius being tortured by Voldemort in the Department of Mysteries. He tries again to illegally use Umbridge's office fire to communicate with the Order of the Phoenix's headquarters to make sure the vision was genuine, and is told by Kreacher the house-elf that Sirius is indeed at the Ministry, before Umbridge catches Harry and his friends in the act. Snape is summoned to provide Veritaserum in order to question Harry, but he claims to have no further stocks of the potion left. Remembering that Snape is also a member of the Order of the Phoenix, Harry gives him a cryptic warning about Sirius's fate, but Snape claims to have not understood it.
Umbridge decides to use the illegal Cruciatus Curse on Harry to interrogate him on Sirius's whereabouts. She also reveals she herself ordered the dementor attack on him, intending to have him either silenced or discredited. Hermione intervenes and in order to create a distraction, convinces Umbridge that they are hiding a weapon of Dumbledore's in the Forbidden Forest. Harry and Hermione lead her into an area of the forest inhabited by centaurs, where Umbridge provokes them into taking her captive. The centaurs are furious upon learning that Hermione used them to do her bidding and turn on the pair, but Grawp arrives and clashes with the centaurs, allowing Harry and Hermione to escape.
Luna, Ron, Ginny, and Neville join them in the forest and all six fly to the Ministry on thestrals, expecting to find and rescue Sirius. Once in the Department of Mysteries, Harry realises that his vision was falsely planted by Voldemort; however, he finds a glass sphere that bears his and the Dark Lord's names. Death Eaters led by Lucius Malfoy attack in order to capture the sphere, which is a recording of a prophecy concerning Harry and Lord Voldemort, which is revealed to be the object Voldemort has been trying to obtain for the whole year, the Dark Lord believing that there was something he missed when he first heard the prophecy. Lucius explains that only the subjects of the prophecies, in this case Harry or Voldemort, can safely remove them from the shelves. Harry and his friends, soon joined by members of the Order, enter a battle with the Death Eaters, during which Bellatrix Lestrange kills Sirius and Voldemort himself arrives to kill Harry, but Dumbledore rescues him and climactically fights the Dark Lord to a stalemate. In the midst of the duel, Voldemort unsuccessfully tries to possess Harry in an attempt to get Dumbledore to kill the boy, then escapes just as Cornelius Fudge appears, finally faced with first-hand evidence that Voldemort has truly returned.
In his office, Dumbledore explains that Snape had understood Harry's cryptic warning, and had subsequently contacted Sirius, learning that he was still at Grimmauld Place. After Harry failed to return from the Forbidden Forest, Snape deduced where he had gone and alerted the Order of the Phoenix, allowing them to save Harry and his friends. It is revealed that during the Christmas holidays, Kreacher had interpreted a command of Sirius's as an order to leave the house, and went to Narcissa Malfoy, the wife of Lucius, and told them about Harry and Sirius's close relationship; Voldemort subsequently realised that he could lure Harry to the Department of Mysteries by tricking him into thinking that Sirius was in danger there.
Dumbledore then explains the prophecy: Before Harry was born, Professor Trelawney predicted that a boy with the power to defeat Voldemort would be born, would be marked as an equal by Voldemort and have power unknown to him, and that one of the pair must kill the other, for "neither can live while the other survives". Voldemort learnt of the first part of the prophecy, and subsequently tried to murder Harry in the belief that he could prevent it from coming true, unaware that he would grant Harry power by doing so. Dumbledore tells Harry that he must stay with the Dursleys for one last summer because by taking Harry into her home, his Aunt Petunia, Lily's sister, seals the protection that Harry's mother afforded him when she died; as long as he is there, he is safe from Voldemort and his followers.
Harry comes to terms with the responsibility of the prophecy, but mourns for the loss of his godfather. Luna comforts him, telling him about her and her father's belief in heaven. Harry then finds an old hand-held mirror in his dormitory that was a gift from Sirius. He realises that Sirius would not want him to be depressed on the matter, and resolves to continue fighting Voldemort.