At the end of Thor, we see Thor holding onto Odin and Loki holding onto Thor. Loki lets go and falls into the wormhole … the deepest, darkest, most secret and strange catacombs of the universe.
There he was enslaved by the Chitauri though we are not certain how. But we know he survived because he's the main villain in the Avengers.
He came back down to Midgard (Earth) controlled by the staff, as you can see by the close ups of his eyes (they are bright and eerily blue like Hawkeye and Erik Selvig when they were being controlled by the staff). He also appears to be bloodied and bruised, walks with a limp, has dark circles under his eyes, and looks dazed. You can see all this in the first scene he appears in when he shows up and begins attacking everyone.
The general consensus is that he was tortured at the hands of the Chitauri and somehow agreed to/was coerced/was tortured into invading earth on their behalf. The movies do not make clear how much of the invasion of Earth was his own will and ambition and how much was actual mind control.
TL;DR: Loki fell into the hands of the Chitauri who tortured him and convinced him to invade earth with their army.
But please feel invited to prove me wrong with HARD EVIDENCE.