I don't know if this counts but Severus Snape is up there. The guy lied for almost twenty straight years at risk of his entire life, and played a huge part in saving the entire world, but he's an unpleasant character and is far from the perfect 'hero'- in fact he's got so many flaws and things wrong that it seems he can't really be considered a hero at all, in many respects.
Also, I would say that Barbossa in Pirates of the Caribbean is a good example. In the first movie he's a villain and we're all happy when he dies, but when he returns and brings back Jack Sparrow and pretty much badasses the whole fight with the East India Trade Company, you think hey actually this guy is kind of good. Also he's hilarious. But then, he makes you hate him again later on and change your mind AGAIN for marooning Jack AGAIN.