Hamlet tells Horatio what happened while he was out of Denmark: he was on the ship to England, when he got the idea to check out Claudius's letter in Rosencrantz and Guildenstern's pack.
Surprise! It tells the king to have Hamlet killed—for the good of the country and all.
But Hamlet has some tricks up his own sleeve, so he alters the letter to tell the king that the bearers of the letter (i.e. Rosencrantz and Guildenstern) should be killed.
Hamlet even sealed the new letter with his father's own signet (a stamp-like object with a design relating to one's title or authority, often on a ring, used to seal official letters) which he conveniently had in his purse.
As luck would have it, the next day was the great sea fight where Hamlet ran off with the pirates. Horatio and the audience know the rest.
Horatio gives Hamlet a chance to be like, "Sorry I killed our friends in a manner that will damn them to eternal Hell," but instead Hamlet just basically shrugs.
They're collateral damage, which is to be expected in a battle between two great forces (Hamlet and Claudius, presumably).
It's logic: Claudius has tried to kill him; Claudius killed his father; Claudius "whored" his mother; and Claudius deliberately stands in the way of Hamlet's access to the crown of Denmark. Ergo, if anything, he would be wrong not to kill Claudius, since he'd only do more harm with time.
But he is sorry Laertes got caught up in the whole thing, and he's actually going to try to make up with him.
Just then, Oscric, a ridiculous member of the court, enters to ask Hamlet if he is willing to fight a friendly duel with Laertes based on a bet. King Claudius has bet six fine horses, six fine French swords, and three beautiful carriages, on the odds that Laertes wouldn't get more than three hits in over Hamlet in a fencing match.
The only other little detail is that the duel has to happen right now.
Hamlet, ever the fatalist, agrees.
Everyone saunters in to watch the duel, including the King (poisoned beverage in hand!) and Queen.
Hamlet, shockingly, is the picture of quiet gentleness.
Claudius offers to put Laertes's hand into Hamlet's, and Hamlet takes the opportunity to apologize: he was crazy. In fact, Hamlet declares that Hamlet himself is but a member of the group of people who is wronged, and that he is a mortal enemy of Hamlet's madness.
Hm, still sounds a little crazy to us.
Laertes hears all of this. He says he's satisfied by Hamlet's apology, but he'd look like a bit of a fool if he just responded, "Thanks for apologizing for killing my dad" and left it at that. Basically, they have to fight to save Laertes's reputation—but it'll be a friendly little fight.
Just before the duel begins, Hamlet declares himself to be the weaker player, but Claudius declares he doesn't mind.
As Osric presents the men the swords, Laertes quibbles, dismissing one as being too heavy. He's clearly picking through the swords, seeming to be choosy, when actually we know he's searching for the sharpened, poisoned sword.
So, apparently he's still going on with his plan, in spite of the seeming truce.
Hamlet is much less choosy than Laertes; he's satisfied and takes a sword after asking only one question about whether the swords are all the same length (which matters for fighting, but not for pulling off a dastardly plan).
Claudius also makes a big show, saying cannons will fire and the King will drink to Hamlet's good hits.
As Hamlet and Laertes cross swords, Hamlet scores the first few points. Claudius offers him the poisoned goblet of wine, but Hamlet declines and keeps fighting. Gertrude then toasts Hamlet with the poisoned wine, and… the Queen drinks.
Meanwhile, Laertes is battling with himself in an aside, wondering if it's not against his conscience to strike Hamlet with the poisoned sword.
Laertes ends up striking Hamlet, and in a scuffle, the two men somehow exchange swords, and Laertes is wounded with his own poisoned sword.
Everyone basically starts dying at the same time.
Laertes declares it fitting that he die by his own sword's treachery. The Queen cries out, and Claudius tries to pass off her falling as a fun game she likes to play when she watches sword matches. And then she finally declares above the uproar that the drink was poisoned.
Hamlet declares treachery is afoot.
Yep, says Laertes. He and Hamlet will expire within a half hour from poisoned swords, and Gertrude will beat them to death by a few minutes.
Laertes immediately declares, in so many words, "It's all Claudius's fault! Claudius did it!"
Hamlet, always thinking quickly, grabs the poisoned sword and stabs Claudius. The people all shout out that it's treason.
Just in case, Hamlet also forces Claudius to drink the rest of the wine.
Just before Laertes dies, he asks for Hamlet's forgiveness; Hamlet isn't any more responsible for his death (and Polonius's) than Laertes will be for Hamlet's.
Hamlet realizes he's about to die, too, so he says he doesn't have enough time to tell the story himself, but Horatio should explain to the world what just happened.
Just then, we hear the sound of approaching soldiers: it's Fortinbras! And his army! Returning victorious from his battle with Poland!
Hamlet opens his final speech with, "O, I die."
Hamlet declares Fortinbras should become the next King of Denmark, probably because everyone in Denmark is dead. "The rest is silence," he says, and dies.
Then Horatio talks about Hamlet's noble heart and how he hopes lovely little angels will bring the sweet prince to his rest.
Then there's lots of drumming as Fortinbras enters with the English ambassadors. Fortinbras is puzzled by all of the dead bodies strewn about.
The English ambassadors say they've just come to report that Rosencrantz and Guildenstern have been killed, according to orders.
Everyone is appropriately shocked, but Horatio promises to explain the entire bloody story.
Fortinbras says it's all really too bad, but he has rights to the throne, and since it's kind of empty, he'll just be settling up there to hear the story.
In the meantime, Hamlet should have a fine burial with the rites of war and soldier's music, since Fortinbras is sure that Hamlet would've been a good king.
And, with a body count of eight (Polonius, Ophelia, Rosencrantz, Guildenstern, Laertes, Gertrude, Claudius, and Hamlet), it's over: The End.