Wormtail approaches Harry, pulls the fabric out of Harry's mouth, and unties him. Harry's injured leg shakes as the Death Eaters close the circle. Harry remembers the short-lived dueling club at Hogwarts and thinks that he's unprepared for this. Voldemort asks Harry to bow, but Harry refuses. Voldemort uses his wand to make Harry bow and then immediately performs the Cruciatus Curse again. Harry ignores Voldemort asking if he wants to be hurt again and knows he's going to die like Cedric. When Harry refuses to answer, Voldemort puts Harry under the Imperius Curse. Harry breaks through it.
Even if Harry was able to make it through the Triwizard Tournament tasks and win the competition, his thoughts here show that he's still entirely unprepared for a real world that includes someone as evil and powerful as Voldemort. In this way, this duel with Voldemort becomes Harry's first real taste of a world unmediated by trustworthy adults, thrusting him into maturity and adulthood before he’s really ready.
Before Voldemort can curse Harry again, Harry flings himself behind the headstone. Voldemort taunts Harry and Harry knows he's going to die. He decides that he's going to die standing. As he jumps around the headstone, he and Voldemort curse each other at the same time. The jets of light meet in the middle and suddenly, Harry's hand is glued to his wand and the beam of light connecting the wands becomes gold. Voldemort and Harry lift off the ground to a clear area and a thousand beams of light enclose them. Harry hears phoenix song and hears a voice in his head saying that he can't break the connection. Harry notices beads on the strand of light between the wands and realizes that he needs to push the beads towards Voldemort. Voldemort seems confused and panicky.
The fact that even Voldemort, a powerful adult wizard, seems afraid of what's happening shows Harry that there's more to the Wizarding world than he can ever learn in a lifetime, and he can't plan for everything. The fact that Harry doesn't panic and instead listens to his instincts and the phoenix song shows that in times like this, Harry is already skilled at drawing his own conclusions and doing what he feels is necessary to win.
Harry concentrates and the bead finally makes contact with Voldemort's wand. Voldemort's wand begins to scream, Harry sees a ghost of Wormtail's new hand, and then a ghostly Cedric appears. An old man, Frank Bryce, appears next and encourages Harry. Then, Bertha Jorkins steps out, followed by Lily and then James. They approach Harry and tell him that when the connection breaks, they'll give Harry time to return to the Portkey and to Hogwarts. Cedric asks Harry to take his body back. Harry breaks the connection and Voldemort's victims converge on their killer. Harry races through the graveyard and reaches Cedric. He grabs Cedric's wrist, Summons the cup, and he and Cedric fly away as Voldemort screams.
When Harry does everything in his power to honor Cedric's ghost's request and take his body back, it shows that Harry understands that the best thing he can do sometimes is to listen to what someone tells him and truly hear what they're saying. At this point, there's no greater kindness that he can do for Cedric; what matters is that Cedric is able to experience dignity in death by not being left to the Death Eaters or to confused Muggles.