@Lexcade on Twitter was wondering about the line between villain and anti-hero. Where it was and how it was defined. So, with my vast experience as a reader (yeah, right) I thought I'd take a shot at it.
A villain is someone who is doing whatever he is doing for personal gain no matter the cost to anyone around him. A villain can be a bank robber or a megalomaniac bent on ruling the world. The defining point is that the character doesn't care about anyone beside himself and his goals. He'll torture, maim and kill anyone who gets in his way as he reaches for his goal. He may or may not be sane but he is always focused on his goal.
Examples are the various Bond villains (especially the ones from the Sean Connery era), The Batman villain Joker, Superman villain Lex Luthor and Harry Potter bad guy Voldemort. They're all focused on their goals and they're all willing to kill to get what they want.
A hero is a selfless individual who looks out for the safety and well-being of others. He'll put his own life on the line to save a total stranger, not because he stands to gain from it, but because it's the right thing to do. The hero attempts at every turn to do no harm to bystanders and to limit damage to personal property. He is a "boy scout" to varying degrees.
Examples of the true hero include just about every superhero from the 1940s on (there are some exceptions and we'll get to those), Joe Friday in Dragnet and just about any character played by John Wayne (again, there are exceptions).
So there's the range from bad guy to good guy. In between we have the anti-heroes. Their reasons for doing what he does, for saving damsels (or dudes) in distress vary greatly. They are almost always characters who go against the grain, who have their own methods for getting things done and who tend to not stand for bureaucratic b.s. They are often loners, usually because they feel the world doesn't understand them and that it's better to be alone than with people that they feel uncomfortable around.
Anti-heroes, unlike the villains, usually has a code to live by. Most often this code involves what they won't do to get the job done. For example Batman has a hard and fast code against killing no matter who the person might be. Wolverine of the X-Men has a general code against harming children, going as far as telling the young Katie Power (of the Power Pack) to keep her eyes closed so she won't see him effectively disembowel the villain trying to hurt them both.
Examples of the anti-hero include Batman and Wolverine as mentioned above, Marvel Comics' Punisher, certain incarnations of James Bond, the Sylvester Stallone character John Rambo, John McClain from the Die Hard movies, and pretty much every other action hero who doesn't fit in to the true hero camp.
So, where's the line? Essentially this: an anti-hero is a hero but without the need to uphold the law or be beholden to anyone. The anti-hero gets the job done. It may require a high body count, it may require a great deal of visceral violence and it will probably require a few well-placed quips, but the job will get done. An anti-hero is not a villain because, unlike the villain, the anti-hero cares if someone innocent gets hurt in the crossfire. The anti-hero can seem to be a villain (the Punisher started out as a Spider-Man villain) but never crosses the line into being purely evil.
Sean Connery's James Bond may throw an electric heater in to a bathtub full of water, killing the henchman through electrocution, but he won't put a bystander danger of his own accord and will, in fact, go out of his way to avoid hurting people who aren't involved in his fight.
John McClain may kill hundreds of the villain's henchmen, but he won't fire in to a crowd because he might injure or kill a civilian.
Anti-heroes will work outside of the establishment if the establishment gets in their way but they'll always come back to the fold in the end because the establishment represents what's right even if it is a pain in the ass.
Boiling it down to its core the thing that sets an anti-hero apart from a villain is the anti-hero's desire to do the right thing. Save the hostages, capture the bad guy, uncover the corruption, whatever it is. The anti-hero is heroic without having to be the boy scout.