Harry Potter and his cousin Dudley Dursley are attacked by two Dementors, but Harry manages to drive the Dementors off with a Patronus charm. Shortly thereafter, the Ministry of Magic detect the act of underage wizardry and attempt to have Harry expelled from Hogwarts immediately, but this is modified to a trial later in the summer. After experiencing horrible nightmares depicting the evil Lord Voldemort's return, Harry is awoken by the arrival of an advance guard of wizards who escort him to the headquarters of the Order of the Phoenix, a secret organization founded by Dumbledore. It is only now that Harry discovers that under the Ministry's influence the newspaper The Daily Prophet has launched a smear campaign against anyone who claims that Voldemort has returned, leaving Harry feeling isolated and betrayed by the Wizarding community. Harry and the other members of the Order fly to 12 Grimmauld Place, the home of Sirius Black, where they meet with Sirius, Remus, Ron, Hermione and others. Later, Ron and Hermione express concern about Harry's situation with the Ministry.
Harry and Arthur Weasley head to the court where Harry's trial will take place, briefly spotting Lucius Malfoy speaking with the minister on their way. With the help of Dumbledore and Harry's neighbour, Mrs Figg, Harry is cleared of all charges at the Ministry and is allowed to return to Hogwarts. However, during Harry, Ron and Hermione's fifth year at Hogwarts School, the Minister for Magic Cornelius Fudge appoints a new Defence Against the Dark Arts teacher, Dolores Umbridge, a Senior Ministry official who refuses to teach practical magic to her students, as the Ministry fears Dumbledore will organize his own personal wizard army. One day during class, Harry is punished for claiming that Cedric Diggory was killed by Voldemort, which according to the Ministry's official policy is a lie. In Umbridge's office, Harry is forced to write "I must not tell lies" repeatedly as punishment. However, the sentence is magically imprinted on his hand instead, causing scarring. Meanwhile, as Umbridge's control over the school increases, Ron and Hermione aid Harry in forming a secret defence group, calling themselves "Dumbledore's Army" or DA for short. Harry, Ron and Hermione start teaching at Hogwarts, training students in defensive spells to become part of the Army. Draco Malfoy and other Slytherin students are then recruited by Umbridge to try to uncover the secretive group, creating the Inquisitorial Squad. Meanwhile, Harry officially begins a relationship with Cho, as they kiss one day after training. In an attempt to tighten her oppressive grip on Hogwarts, Umbridge dismisses Professor Sybill Trelawney and tries to have her banished from Hogwarts, which is only prevented after Dumbledore's intervention.
Harry's nightmares continue, including a dangerous attack upon Arthur Weasley in the Department of Mysteries involving Nagini, Lord Voldemort's snake, which happens to turn true. Harry's anger starts to get out of control, as his mental connection to Voldemort grows stronger. Fearing Voldemort will exploit his connection with Harry, Dumbledore immediately instructs Professor Snape to give Harry a crash course on Occlumency lessons in an attempt to block Harry's mind from the Dark Lord's influence.
Meanwhile, Bellatrix Lestrange escapes from Azkaban along with other Death Eaters after one of the prison walls is damaged by lightning flashes. At Hogwarts, Umbridge, Filch and her loyal Inquisitorial Squad, uncover Dumbledore's Army after interrogating one of the students, Cho Chang for whom Harry had developed intense feelings. Dumbledore is questioned and makes an impressive escape as Fudge orders his arrest. With Dumbledore gone, Umbridge becomes the new Headmistress, and her sinister dominance over the school continues. Later, Hagrid introduces Harry, Ron and Hermione to his half-brother giant, Grawp. Later, Harry reverses Snape's spell by glimpsing into Snape's mind. It is then that Harry learns that Harry's father used to bully Snape when they were students at Hogwarts, which appears to be the real cause behind Snape's resentment towards Harry. Meanwhile the Weasley twins, Fred and George formulate a plan of their own.
During an O.W.L. exam, the Weasley twins execute their plan, launching a firework display in the great hall causing chaos for Umbridge, Fudge and the students of Slytherin house. As the students cheer joyously outside, Harry suffers a vision of Sirius trapped within the bowels of the Ministry being interrogated about the Order. Harry, Ron, and Hermione rush to search for Sirius, but Umbridge, soon after, catches the trio attempting to use the Floo Network, and begins interrogating Harry. She calls for Professor Snape to bring Veritaserum for use during her interrogation, as she has for all of her previous interrogations, but Snape tells her that the supply has been exhausted. Hermione then tricks Umbridge into entering the Forbidden Forest along with Harry and her in search of a faux weapon, really leading her to the hiding place of Grawp who has since freed himself from the tree he was latched to, when a herd of centaurs, who have their own issues with the Ministry, emerge and carry the Headmistress into the darkness. Hermione and Harry head back to Hogwarts to find Ron and other DA members, Luna Lovegood, Neville Longbottom, and Ginny Weasley, the group decided to fly to London by way of the Thestrals (winged horse-like magical creatures) to the Department of Mysteries of London City in an attempt to save Sirius.
The six enter the Department of Mysteries, where they uncover a prophecy involving Harry and Voldemort, but are soon ambushed by Death Eaters, including Lucius Malfoy and Bellatrix Lestrange, Sirius's deranged cousin. After a brief battle and a failed escape attempt, the Death Eaters, manage to take Ron, Hermione, Luna, Neville, and Ginny as hostages threatening to kill them if Harry does not hand over the prophecy. Sirius appears, with the other members of the Order of the Phoenix, and attacks the Death Eaters causing Lucius to drop the prophecy, which then shatters. A battle erupts as the Death Eaters try to stop the students from escaping, resulting in Sirius's death at Bellatrix's hand. Back in the Atrium, Harry corners Bellatrix, where he struggles with his desire to enact the Cruciatus curse. Voldemort himself appears, ready to kill Harry when Dumbledore emerges to face his battle against Voldemort.
A brief but furious duel between Voldemort and Dumbledore takes place, in which Bellatrix escapes through the Floo Network. When Voldemort disappears, and the battle seems over, Harry suddenly finds himself possessed by Voldemort -- recalling images of his past, of his family and his friends but throws off Voldemort's influence, stating that he is stronger than Voldemort through his friends and his ability to love. Ministry officials, including Fudge, hastily arrive via the Floo Network moments before Voldemort disappears.
In the aftermath of the battle, the Ministry is forced to end their smear campaign and Umbridge is removed from Hogwarts, awaiting a formal investigation. Dumbledore explains that he had attempted to distance himself from Harry all year, hoping it would lessen the risk of Voldemort discovering and using the connection between the two. While the students head home from Hogwarts at the end of the academic year, Harry tells his friends that they have one thing Voldemort does not: love, a power worth fighting for.