Harry sacrificed his life to Voldemort in Harry Potter and the Deathly Hallows, but was he really dead in those moments following the Dark Lord’s Killing Curse? The reveal that Harry would have to die for the fragment of soul inside him to be destroyed was the overarching twist of the series, and it was certainly an effective one. The drama was only heightened after Harry walked away from the incident, Horcrux free, and battled it out with Voldemort one last time, thus saving the wizarding world. However, the Harry Potter series remained pretty covert with the details of how all this worked.
https://screenrant.com/harry-potter-really-die-deathly-hallows-explained/