Hamlet is a tragic hero and somewhat of an anti-hero. He is tragic because in his quest for revenge, others around him must suffer. And he suffers himself. He is an anti-hero because he has heroic qualities but he is more of a philosopher than the archetypal hero of deeds and actions. In fact, when the play begins, Hamlet is a quiet, brooding, passive man. Even when he begins his plan of revenge, he is still the thinking hero rather than the acting hero: until the end of the play.
That being said, I think you can certainly call him an intellectual type of hero. His superior intelligence demands that he analyze every action he may commit. That is why it takes him so long to exact his revenge. He is a philosophical and psychological hero. His moral compass is illustrated in the fact that he agonizes over every decision trying to think of all ethical implications.
Anti-hero doesn’t have to mean the opposite of a hero, such as a villain. Anti-hero can mean a character that is heroic, but in ways that are different from traditional definitions of heroes such as Odysseus. Hamlet is tragic because those around him must suffer (namely Ophelia and his mother) while he thinks his way through the play.
I don’t think you can consider him a villain in any way. Polonius’ death was accidental. His cruelty towards Ophelia is a reflection of his scorn for women and marriage after his mother’s “hasty” marriage to Claudius. That is irresponsible but understandable. Gertrude and Laertes also die because Hamlet’s plan goes awry. These are unfortunate events and Hamlet is partially responsible, but none of this would have occurred had Claudius not instigated the whole thing. Hamlet’s actions do lead to fatal consequences, but he is not a villain.
Because Hamlet has the best of intentions, I can only see him as a hero. He is a tragic hero, of course, by Aristotle's definition. He is a great man in that he is loved by the people. There is support for this in that he is not only an ethical man, but a moral one as well. He knows what is right, but he also acts upon it. He dies, and seemingly, his procrastination is the reason for his death.
As so many scholars note, it is his failure to act quickly that causes the destruction of most of the characters in the story. Had Hamlet killed the new king at his first opportunity, Claudius would not have been able to carry out plans to protect his place on the throne and Hamlet would not have had to continue with his pretense of madness, thus saving Ophelia. At the same time, Hamlet is a man of his time (or at least Shakespeare's): he believes that to wrongfully kill a king will cost him his eternal soul. And the Elizabethans believed that ghosts could be authentic or evil spirits brought about to wreak havoc in the lives of the living. Looking for proof reflects Hamlet's desire to carry out plans that have merit. Hamlet is a hero, but he over-analyzes and misses his window of opportunity. For me, this shows him to be completely human. Driven by a promise made to his father's ghost, Hamlet makes the best of a situation he is ill-prepared to handle, seemingly knowing nothing of Claudius and his kind.
It seems to me Hamlet tries to be a villain; however, each time he does, he fails. He tries to exact revenge on Claudius but his religious beliefs, in part, prevent him from doing so and Claudius goes on to be the cause of both Gertrude's and Laertes' deaths. He tries to take decisive action but ends up killing an innocent man (Polonius). He tries to be a chauvinist to protect the woman he loves (Ophelia) and she commits suicide. He is an intellectual and not particularly well suited in the role into which he has been thrust: avenging son.
Hamlet, according to renown critic Harold Bloom, is a villain-hero whose transcendence finally triumphs, even though he is responsible for eight deaths. Says Bloom,
Hamlet, more than Falstaff or Cleopatra, is Shakespeare's great charismatic, but he bears the Blessing as though it were a curse.
Some critics perceive Hamlet as Shakespeare's own consciousness. But, one thing is certain: Hamlet is contradiction. He grieves, yet he expresses his grief with extraordinary verve; his continuous wit belies his melancholy. Hamlet is a man of self-revision.
Actually, there are some villainous qualities to Hamlet's character that have been noted by critics (see Hamlet Haven Online for some relevant outlines of Hamlet Criticism).
Most notably, he behaves rather like a Stage Machiavel in his tricksy behavior onstage and his dark, biting sense of humor. In fact, as the play goes along, Hamlet becomes more and more like the Machievel (and less like the philosopher, the thinker) than he was in the beginning of the play. The hasty leap into Ophelia's grave, for instance, to fight Laertes over the question of who loved her best does not seem to fit the brooding, quiet Hamlet of the first several scenes.
It can be argued that this darker, more saturnine streak in Hamlet is a reference to one of the play's sources, the Amleth by Saxo Grammaticus, where Amleth is a much darker character who feigns madness in order to trick his foes to their deaths and who marries two women in two different lands. Of course, Saxo's work is not a tragedy, nor does his Amleth need to conform to any Aristotelian concepts, but the "thinking man" who contemplates his way through the first acts of Hamlet is surely transformed in Shakespeare's play after the Mousetrap into one who, using his own words, could "drink hot blood" (which might connect him even with dark magic, witchcraft).
Whether or not Hamlet returns from his intended journey toward death in England as one who really can wait, "let be," and allow occasion to give him the opportunities to avenge his wronged father is debatable, particularly since his apology to Laertes at the beginning of the final scene shows Hamlet, in effect, fibbing: he says that he did the wrong to Laertes and his family in madness, which we know is not true, unless we are to enlarge our definitions of insanity to include that wild moment when he thinks he's got Claudius behind the arras and kills Polonius instead (and is not terribly sorry for it, either, cracking sardonic jokes to Claudius and others about the man's corpse with a wicked, sharp wit).
Finally, there have been those critics who have asked whether it is even possible to have a classical-type tragedy in a Christianized culture like Shakespeare's. Given the Christian culture's mandates to "turn the other cheek" and to keep one's own sights focused on heaven, rather than on acts of vengeance on earth, Hamlet would seem to fit more into the category of villain.
He dies not only with the suffering of many others in his realm connected with his vengeance but also with Polonius, Laertes, and Claudius dead by his own hand (though Laertes has forgiven him-- but if it is a Christian afterlife, can Laertes' forgiveness absolve Hamlet?). From the Christian perspective, it would seem that Hamlet would be going to hell (and not even the purgatory that his father was sent to, having died without absolution for his sins).
However, unlike the Machiavel, Hamlet uses his final moments alive to be the king he had never been allowed to show he could be: he saves the life of a subject (he stops Horatio from committing suicide) and he provides for a peaceful succession after his death.
Does this mean that Hamlet does go to his "rest," sung there by "flights of angels"?
I'd like to think so.
But there are simply no easy answers when it comes to Hamlet.