It all went down tonight during a homecoming dance thrown at Tyler's.
Damon came up with a plan to kill Klaus and it involved having Katherine pose at Elena. This way, when Mikael followed through on his threat to kill Elena, thereby ending Klaus' ability to make Hybrids, Klaus would give in, fight Mikael and be killed.
But Klaus, who had collected a Hybrid army and was surrounding the house with him, called Mikael's bluff. He proceeded to kill "Elena," Klaus was distracted and Damon swooped him to dagger him with the special stake - but then Stefan pulled Damon off him! Klaus grabbed the dagger and killed Mikael!
Klaus then rewarded Stefan by giving him back his freedom. Later, we saw Stefan in a car with Katherine and learned that Klaus had told her (when he thought she was Elena) that the Hybrids were instructed to kill Damon if he was killed. Therefore, Stefan actually acted to save his brother's life when he also saved that of Klaus.
Finally, the episode/year ended with one more surprise: Katherine had taken all the corpses of the Originals, who Klaus now wanted to awaken with Mikael dead. Stefan called Klaus to taunt him about this fact and we were left with one seriously pissed off Original.