A ghost resembling the recently deceased King of Denmark stalks the ramparts of Elsinore, the royal castle. Terrified guardsmen convince a skeptical nobleman, Horatio, to watch with them. When he sees the ghost, he decides they should tell Hamlet, the dead King's son. Hamlet is also the nephew of the present King, Claudius, who not only assumed his dead brother's crown but also married his widow, Gertrude. Claudius seems an able King, easily handling the threat of the Norwegian Prince Fortinbras. But Hamlet is furious about Gertrude's marriage to Claudius. Hamlet meets the ghost, which claims to be the spirit of his father, murdered by Claudius. Hamlet quickly accepts the ghost's command to seek revenge.
Yet Hamlet is uncertain if what the ghost said is true. He delays his revenge and begins to act half-mad, contemplate suicide, and becomes furious at all women. The Lord Chamberlain, Polonius, concludes that Hamlet's behavior comes from lovesickness for Ophelia, Polonius's daughter. Claudius and Gertrude summon two of Hamlet's old friends, Rosencrantz and Guildenstern, to find out what's wrong with him. As Polonius develops a plot to spy on a meeting between Hamlet and Ophelia, Hamlet develops a plot of his own: to have a recently arrived troupe of actors put on a play that resembles Claudius's alleged murder of Old Hamlet, and watch Claudius's reaction.
Polonius and Claudius spy on the meeting between Ophelia and Hamlet, during which Hamlet flies into a rage against women and marriage. Claudius concludes Hamlet neither loves Ophelia nor is mad. Seeing Hamlet as a threat, he decides to send him away. At the play that night, Claudius runs from the room during the scene of the murder, proving his guilt. Hamlet gets his chance for revenge when, on the way to see Gertrude, he comes upon Claudius, alone and praying. But Hamlet holds off—if Claudius is praying as he dies then his soul might go to heaven. In Gertrude's room, Hamlet berates his mother for marrying Claudius so aggressively that she thinks he might kill her. Polonius, who is spying on the meeting from behind a tapestry, calls for help. Hamlet thinks Polonius is Claudius, and kills him.
Claiming that he wants to protect Hamlet from punishment for killing Polonius, Claudius sends Hamlet to England with Rosencrantz and Guildenstern. But Claudius sends with the three men a letter asking the King of England to execute Hamlet. Meanwhile, Polonius' son, Laertes, returns to Denmark from France to get revenge for his father's death. Claudius convinces Laertes the death is Hamlet's fault. When a pirate attack allows Hamlet to escape back to Denmark, Claudius comes up with a new plot in which a supposedly friendly duel between Hamlet and Laertes will actually be a trap, because Laertes's blade will be poisoned. As a backup, Claudius will also poison some wine that he'll give to Hamlet if he wins.
Meanwhile, grief drives Ophelia insane, and she drowns in what seems to be a suicide. Hamlet arrives just as the funeral is taking place. He claims to love Ophelia and scuffles with Laertes. Back at the castle, Hamlet tells Horatio he switched the letter sent to England: now Rosencrantz and Guildenstern will be executed. He also says he is ready to die, and agrees to participate in the fencing match.
During the match, Gertrude drinks to Hamlet's success from the poisoned glass of wine before Claudius can stop her. Laertes then wounds Hamlet with the poisoned blade, but in the scuffle they exchange swords and Hamlet wounds Laertes. Gertrude falls, saying the wine was poisoned, and dies. Laertes reveals Claudius's treachery. Hamlet kills Claudius, and exchanges forgiveness with Laertes. Laertes dies. As Hamlet dies, he hears the drums of Fortinbras's army marching through Denmark after a battle with the Polish, and says Fortinbras should be the next King of Denmark. Fortinbras enters with the Ambassadors from England, who announce that Rosencrantz and Guildenstern are dead. Horatio tells Hamlet's story as Hamlet's body is taken offstage with the honors due a soldier.