Montezuma more or less surrendered to Cortez because he saw him as Quetzalcoatl, and the troops didn't. Cortez paraded him as a prisoner in an attempt to get the troops to join him in surrender, but the troops stoned him instead. The injuries were such that the Spanish expected him to survive, but apparently he had lost the will to live.
The empire had made many, many enemies, so Cortez had a good many local allies when he attacked Tenochtitlan.
Cortez was very, very good at his job. Partly because he was much less of an sadistic asshole than your average Conquistador (not a major compliment). Montezuma was not a very good Emperor, and the empire had grown soft from being on top too long.
Still, it was rather a major upset if you look at it in strictly secular terms. On the other hand, when a pissed-off major deity shows up to destroy his people, all bets are off. And Cortez (though he certainly didn't think so) was the Plumed Serpent, returning as predicted (to the day) in his cloud-ship to destroy the empire for indulging in human sacrifice.