Harry Potter and the Deathly Hallows
How we cite our quotes:
And Dumbledore had known that Harry would not duck out, that he would keep going to the end, even though it was his end, because he had taken trouble to get to know him, hadn't he? Dumbledore knew, as Voldemort knew, that Harry would not let anyone else die for him now that he had discovered it was in his power to stop it. (34.7)
Dumbledore knew Harry's character, and thus knew what choice the young man would have to make. He used this knowledge of Harry to ensure that his plans would fall into place, making it difficult to figure out if this is predetermined by Dumbledore, or a choice freely made by Harry, or both.
"I am sorry too," said Lupin. "Sorry I will never know him – but he will know why I died and I hope he will understand. I was trying to make a world in which he could live a happier life." (34.57)
Lupin, here speaking of his son Teddy, is sure about his choice to fight, even though it means that he'll never get to know his only child. He speaks with conviction, knowing that he did all he could to help build a future.
"But…" Harry raised his hand instinctively toward the lightning scar. It did not seem to be there. "But I should have died – I didn't defend myself! I meant to let him kill me!"
"And that," said Dumbledore, "will, I think, have made all the difference."
Ah… so, we see, it's not Harry's actual demise, but his decision to die that counts. This choice, made of his own free will, and for the sake of others, is what saves him in the end.