What happened to Neo in the last part of trilogy when the machine gave him the power to battle with Agent Smith. Was he dead?
Neo was effectively the result of a 'Glitch', which is why he was able to achieve impossible things whilst inside the progam. He was able to bypass it's restrictions, and render it's security and protection meaningless (as if the Hacker occupation wasn't subtle enough a clue).
Agent Smith was the result of the Matrix automatically trying to correct this Glitch through balance; much like a human immune system creating anti-bodies to attack a virus, which in theory is what Neo had become.
The Matrix NEEDED Agent Smith in order to 'balance it's spreadsheet', so to speak..
If Neo was defeated by the Anti-bodies (Smith), there is no longer any need for those anti-bodies to exist and so the Matrix will automatically restore the balance by deleting Smith.
The agreement made by Neo and the Source (an expression of the Matrix's interface) was one of appeasement, not surrender. He would effectively sacrifice himself for a ceasefire agreement with Zion.
The idea that the Matrix is of an intrinsically self-balancing, auto-correcting nature is actually sowed in the first film, during Smith's 'Equilibirium' speech.
I guess they call that Foreshadowing...
No. If you watch carefully, they needed Smith to absorb Neo - when that happened, only THEN did the machines/Architect gain power over Smith (via Neo's jacked-in body) and delete Smith.
While Neo was alive during the battle, but there's no telling what happened in the aftermath. Seems that he died when he was consumed by Smith and the connection to the Matrix was unplugged, but there's no clear canon confirmation of that.