Harry arrives in the Great Hall as McGonagall announces the evacuation plan. He looks around for Ron and Hermione as Voldemort's voice echoes through the hall, saying that fighting is useless and asking for Harry by midnight. Pansy Parkinson shrieks and points to Harry, but Gryffindors, Hufflepuffs, and Ravenclaws stand in front of him. The younger students evacuate, leaving the older students who want to fight. Kingsley announces the battle plan and McGonagall sends Harry off to look for the diadem. Harry tries not to panic and checks the Marauder's Map for Ron and Hermione. He races back to the Great Hall to find Nearly Headless Nick and asks who the Ravenclaw ghost is. Nick points Harry to the Gray Lady.
That Harry feels so lost without Ron and Hermione speaks to the fact that he now truly understands that he needs them and his community at large in order to be successful. While receiving the support of the Hufflepuffs, Ravenclaws, and Gryffindors is nice, it doesn't give him the same sense of security that he gets from knowing that his best friends are safe and around to support him. Calling on Nick, a ghost, shows that Harry is continuing to recognize the importance of asking for help, even from those who might not be immediately obvious.
Harry races after the Gray Lady and begs her to help him find the lost diadem. She's disdainful at first, but Harry says he needs it to defeat Voldemort and save Hogwarts. She admits that, in life, she was Helena Ravenclaw, the daughter of Rowena Ravenclaw, and says that she stole the diadem. Rowena never knew, but sent the Bloody Baron to fetch Helena when Rowena was close to death. He killed Helena and then himself, while the diadem stayed hidden in a hollow tree in Albania. She admits that she told this story to Tom Riddle, and Harry realizes that Voldemort must've brought the diadem back to Hogwarts when he asked for a job. Harry thanks the Gray Lady and wonders where the diadem is.
Harry's conceptualization of this battle as being one over Hogwarts itself shows again that what he and Voldemort are really fighting for is the right to tell young people what is right—whether they'll learn tolerance and kindness, or selfishness and greed. The Gray Lady's willingness to help Harry shows that even the ghosts believe in this goal and are willing to admit their faults in order to help Harry right past wrongs and, hopefully, restore the school to its former glory.
Hagrid suddenly crashes through a window next to Harry with Fang. He explains that he and Grawp heard Voldemort from up in their cave and smashed through the boundary. They stride through the castle looking for Ron and Hermione. They pass the shattered gargoyles that guarded the staff room, and Harry suddenly realizes where the diadem is: in the Room of Requirement. Harry passes Fred and then comes upon Aberforth, who asks Harry why he didn't keep a few Slytherin kids hostage. Harry says that Voldemort wouldn't care and Dumbledore wouldn't have done it. Harry races on and finally finds Ron and Hermione. Ron explains that they went down to the Chamber of Secrets, destroyed the cup with a basilisk fang, and grabbed more fangs so they can destroy the last Horcrux.
Harry is right; while stealing children may sway some of Voldemort's followers, Voldemort himself won't care that there are loyal children held hostage—if only because he believes that he's going to be victorious and that there's nothing to worry about in the first place. The revelation of what Hermione and Ron were doing shows Harry again that he can rely on his friends to use their individual experiences to come up with plans and effectively execute them, leaving Harry in a place where he can do the same.
Harry quickly tells them where the diadem is and they run to the Room of Requirement. There, they find Neville's gran and Tonks. Tonks runs to find Lupin and Neville's gran goes to help Neville. Ginny is delighted to leave the room. Ron sharply says that they need to evacuate the house-elves, and Hermione races to him and kisses him. Harry begs them to wait. Harry asks the Room of Requirement for "the place where everything is hidden." The trio enters. Ron is shocked that Tom Riddle thought he was the only one who'd ever hidden things here—the room is the size of a cathedral and filled with items.
Ron's assessment of Tom Riddle's incorrect beliefs shows again that what plagues Voldemort is the idea that he's smarter and cleverer than his opponents when there's plenty of evidence that this isn't true, from this room filled with hidden objects to the missing Horcruxes. For Voldemort, then, it becomes even more crucial in his mind to rely on the Elder Wand and brute strength, which he believes will be stronger than knowledge and humbleness anyway.
Harry leads them to where he remembers seeing the diadem. Hermione tries to Summon it, and then they split up. Just as Harry sees the diadem, Draco, Crabbe, and Goyle stop him. Crabbe softly says that they're going to capture Harry for Voldemort and then sends a tower of junk toppling near Ron. Malfoy tries to stop him, insisting they need to get the diadem, but Crabbe says he doesn't listen to Draco anymore. When Ron shouts for Harry, Crabbe shoots a curse at Harry but hits the diadem, sending it flying. He aims a Killing Curse at Hermione. Hermione shrieks and points to where Ron and Crabbe are running at them, flames pursuing them.
In this moment, Draco seems as though his life has totally run away from him: his cronies will no longer listen, and his family is in danger of getting even further on Voldemort's bad side. That most of the flying curses are coming from Crabbe and Goyle suggests that Draco mostly wants to get out of this alive and to bring honor to his family; it's less important to him to actually kill Harry.
Draco drags Goyle, who's Stunned, as Crabbe runs ahead. Harry, Ron, and Hermione stop as the fire mutates into serpents and dragons. Harry grabs two brooms and they fly above the flames. He swoops down when he sees Draco, and Ron angrily dives for Goyle. They fly to the door, Harry grabs the airborne diadem, and they close the door behind them. Malfoy chokes and Ron says that Crabbe is dead. They realize that Ginny is missing and see that the diadem, black with soot, seems to be bleeding. It breaks apart and Hermione whispers that Crabbe conjured Fiendfyre, one of the only ways to destroy Horcruxes.
Harry and Ron's choices to rescue Draco and Goyle show that they also recognize that their actions matter—letting Draco and Goyle die, especially when Draco seems questionably committed to the cause, would be unconscionable. With this, Harry and Ron are then able to reassert themselves as good guys, and give Draco and Goyle the opportunity to start making choices that will make them better people in the long run.
Harry, Ron, and Hermione see Fred and Percy dueling masked Death Eaters. The trio runs up to help as an explosion throws them all back and blasts open the castle wall. Harry is bleeding when he stands up. He sees Percy and Ron shaking Fred, who is dead.
Fred's death makes it abundantly clear for Harry that this battle is the one in which everyone has to deal with the possibility of sacrificing themselves—and in doing so, of dying on their own terms.