They fight for the good guys. They might even believe in the cause. But they are a hero only in name.
They are antiheroes who have a fundamental lack of empathy, a sociopathic disregard for human life. They may be motivated by boredom, or by some sort of carrot-and-stick arrangement - a chip in the head, an attachment to some person or thing that requires them to do good, or a pragmatic code that prevents their truly inhuman nature from landing them in jail. Sometimes they may be a Reluctant Psycho, whose attempts to do the right thing are obstructed by their own pathology.
They may solve their problems in much the same way as a villain would—ruthlessly manipulating and killing their way to their goal. They may routinely torture, murder, and commit evil acts nearly as bad as the Big Bad. They'll do whatever it takes to win. The people they fight beside worry about their behavior, but feel "At least they're on our side."
Compare Heroic Comedic Sociopath, for when this kind of behavior is Played for Laughs. Also compare Nominal Hero, a character who fights for a heroic cause, but couldn't care less about actually doing good deeds, and Token Evil Teammate, which he will be if a team player.
Examples:
open/close all folders
Anime and Manga
Alucard from Hellsing. Has no regard for human life unless told otherwise, but deep down he admires humanity anyways will kill if ordered or if allowed and enjoys the thrill of war.
Mello from Death Note a ruthless mafia boss whose methods include kidnapping, extortion, and killing his own men and anyone who gets in his way but he is technically speaking on the same side as the detectives.
While L doesn't kill (or at least take the act upon himself) he's not above manipulating, kidnapping, and torture to get the answers.
Near is even more manipulative than L and treats the case like it was a game or puzzle and the other people in it as expendable pawns.
Guts in his days as the vengeance-driven Black Swordsman from Berserk was very much this trope.
Comic Books
Rorschach of Watchmen is one of the better-known examples, being more than willing to torture and kill if he believes good will come of it. He is also the target of a large Misaimed Fandom that admires his absolute dedication to his cause.
The Punisher. All his enemies are mob bosses and criminals, but his ultimate goal isn't to catch them or stop them, but to kill them.
The Spectre is such a sociopath that the only reason he isn't a well-meaning villain is that God keeps him bound to a human soul, to give him a conscience and sense of proportion. It works... barely. Sorta. If you stretch the definition of "proportion".
The Scarab, the source of Blue Beetle's powers, will default to lethal force for almost any situation. Thankfully, Jaime keeps it in check. It starts to get better with Jaime's influence.
Films — Live-Action
Riddick from The Chronicles of Riddick series, at least mildly. He's more of a survivor than a sociopath, though Fridge Logic would suggest he's done a fair amount of killing over his life to earn a trip to a triple-max prison. He certainly has nothing against killing when it benefits him, at any rate. Just make sure you mind the children. Lookin' at you, Johns.
Over the course of Falling Down, Bill Foster transitions into this.
Daniel Plainview in There Will Be Blood starts out as a borderline psychopath with a few tenuous links to humanity, and ends the film as a full-blown Villain Protagonist.
Depending on the actor, James Bond is a borderline case. Being a 00 agent practically requires it, as one has to kill in cold blood, that is without the deceased having been any direct, active threat to the agent.
Live-Action TV
Dexter Morgan, in the TV show Dexter, is a prime example. A Serial Killer (albeit of other killers) who has to emulate emotions to go unnoticed by others, and is only motivated by his urge to kill.
In the 4th, 5th and 6th seasons of Buffy the Vampire Slayer, the soulless vampire Spike plays this role, at first against his will, under the influence of an implanted chip that causes him pain when he attacks something with a soul. Now, his only outlet for his violent predilection is beating up monsters and demons. He sides with the heroes more out of boredom, looking for something to do. Later, he begins to do good for the love of a female character, but only because that's what she would want him to do. His transition to true selflessness occurs without him ever becoming capable of the soulful qualities that distinguish humans from Buffyverse vampires; for that reason, his final act of Season 6 is to seek a real soul.
In the 5th season of Angel, the vampire Harmony works for the good guys, but her motivation is her own personal development. She does good because it seems like an interesting thing to do.
In Sons Of Anarchy, this applies to pretty much everyone in SAMCRO. Tig is the leading example in the early episodes, but he's overpaced by Happy. While the club watches an IRA member torture a traitor, most are shown to be either stoic or disturbed by the display. Happy is smiling.
Shane in The Walking Dead slowly slides into this role. By the second season when he shoots Otis in the leg and leaves him to be killed by zombies he's this fully.
In Doctor Who, the later regenerations of the Doctor constantly struggle against becoming this. During "The Waters of Mars" the Tenth Doctor ended up going so completely off the deep end, he briefly styled himself as "The Timelord Victorious" and was willing to break time itself in half to save people, even if they didn't want him too.
Literature
This is how the main character of The Takeshi Kovacs Series views himself. Several times, he describes the traits needed to qualify for Envoy training as "psychopathic tendencies and a sense of team spirit", at least one of which he had instilled during time in the military. While he has enough of a conscience to Pet the Dog for those who he feels to be the victims, he has no problem with permakilling or torturing anyone who interferes with his goals.
Several characters in Peter Watt's Blindsight; most prominently Jukka Sarasti: a potential murderer, a sociopathic vampire, but one who leads the crew against impossible odds, and who is possibly going out of his way not to offend their sensibilities.
Like his television version, Dexter Morgan in Dexter in the Dark and subsequent novels.
Severian the Torturer from the Book Of The New Sun series by Gene Wolfe. His values are so far astern from the readers sensibilities that he sometimes comes across as shockingly cruel. In some instances, it seems he is ambiguous when describing events that are of great moral relevance to the reader, apparently because he sees no ethical dilemma in them. He shows a mixture of traits, some of which may be sociopathic, others which may indicate a place on the autism spectrum.
Professional Wrestling
A lot of wrestlers who either have monster gimmicks or spent a long time as a heel will become this after a Heel Face Turn.
This happens in Exalted if you have Compassion 1. Alchemicals with high Clarity are explicitly spelled out as not examples - they're emotionless, not wantonly cruel - but those infected by Gremlin Syndrome may well attempt to continue fighting the good fight even as their condition instils a psychotic desire to destroy and maim.
Video Games
Morrigan of Dragon Age: Origins is one of the Stupid Evil variants; her answer to everything tends to be "Eh, we don't need to help them, let's just kill everyone." This has at least some justification since her only social interaction for most of her life came from her mother, who might have intentionally crippled her emotionally in order to make her easier to eventually possess.
The Warden can be played as such, which actually resonates with their entire order. Depersonalization is one of the reasons why the Wardens are such effective warriors, as we are often reminded, the Grey Wardens can and will do whatever it takes to defeat the Darkspawn. Even if it means razing a city to the ground to save the people within.
The Legion of the Dead are also comprised of this. Exiles, criminals, murderers and even rapists from Orzammar are accepted as members, who hold their own funerals when they join, consider themselves dead and are willing to spend their last days waging guerrilla warfare and full head-on assaults against the Darkspawn horde.
Alex Mercer from Prototype is a very complex case, but he ends up being well-intentioned in the end, saving New York from destruction. Doesn't prevent him from being an Axe CrazyPsycho Prototype who savagely kills his enemies, consumes people (though the player can choose whether to eat civilians or not) and has a hard backstory behind him. Though by the time it gets around to the second game he has become a Complete Monster and the new antagonist.
Web Comics
In The Order of the Stick we have Belkar, an Axe CrazyKnife Nut halfling. Word Of God makes it VERY clear that Belkar is 100% Chaotic Evil. For most of his screen time he fits better into Heroic Comedic Sociopath, though there have definitely been moments where his impulsive bloodlust causes drama and even setbacks for the rest of the team. For example, during Roy's afterlife judgement it's mentioned that Belkar would normally cause Roy a lot of karma demerits if the team weren't so good at directing Belkar's violence toward the villains.