First, Neo never did die. The brain lives on while the heart stops. We see this all the time in movies and medical shows that always show shock treatment being given to people whos hearts have stopped. Neo simply wasn't "pronounced" dead yet, medically speaking. Who knows exactly how conscious a person is when their heart is stopped.
In The Matrix Online (a video game that takes place after M3, with a storyline that has the Wachowskis' approval), the machines give all redpills emergency jack-out protection - in other words, just before they die (no matter how the death occurs), they wake up as their RSI is automatically transferred back to the real world. If this can be done for all redpills who jack into the Matrix ver. 7, it seems unreasonable not to assume that the One (the most critical component of the Matrix system) is given this same protection in ver. 6 and all previous versions.
Furthermore, dying is a bendable/breakable rule in the Matrix just like every other rule. Consider that the kid from Kid's Story was able to self-substantiate (wake himself up from the Matrix). It's not made clear whether his moment of death prompts him to self-substantiate, or if he self-substantiates right before hitting the ground. The latter case would suggest that the kid was able to make his RSI in the Matrix die at will, which is the opposite power that would be necessary to will a dead RSI back to life in the Matrix as Neo did. But if he self-substantiated upon impact, this anomalous ability would offer a contributory explanation to the auto-jack-out protection. The kid wasn't able to make himself wake back up in the Matrix two minutes after dying like Neo did, but at least it allowed his body in the real world to overcome Morpheus's rule that "the mind makes it [physical harm or death in the Matrix] real."
So, as Neo gained power from the rejection code that was funneled into his consciousness, part of that code may have included the anomalous ability to overcome the illusion of death. Neo's rejection of the Matrix could be so strong that he can reject even death itself. At the least, I think this is what enables Neo to block Smith's attempt to copy over him. It seems there are two explanations at play here: one explanation that is rooted in machines (auto-jack-out mechanism making it impossible for the One to die) and another explanation that is rooted in humans (anomalous rejection of the Matrix's "death" rule).
In M2 after Trinity dies, Neo starts talking to her and says, "I know you can hear me." How exactly does he know? It seems that he is referencing the time when Trinity spoke to him while he was dead, suggesting that Neo could hear Trinity speak when he was in that state. What this implies is that Neo's "half-dead consciousness" was taking place in the real world. Once Neo realized he didn't have to die, his RSI was reinstated inside the Matrix.
Neo's Powers | Neo's Powers: Vision of Future |