The film begins with a flashback revealing Gollum's origin: Once a Stoor-Hobbit named Sméagol, he murdered his cousin Déagol to possess the One Ring, which gradually transformed him into a slimy, wretched creature enslaved to "the precious". Gollum takes Frodo and Sam to Minas Morgul. Aragorn, Legolas, Gimli, Gandalf, Théoden and Éomer meet up with Merry, Pippin and Treebeard at Isengard, now under the Ents' control, where Gandalf concludes Saruman will pose no further threat. They also recover a palantír from the ruins. The group returns to Edoras, where Théoden holds a feast in celebration of the victory at Helm's Deep. Pippin's curiosity gets the better of him, and he looks into the palantír, where he sees a vision of a dead white tree; he is seen and mentally interrogated by Sauron, though Pippin tells him nothing regarding Frodo and the Ring. From this, Gandalf deduces Sauron is planning to attack Minas Tirith, and he rides off there with Pippin. In the meantime, Arwen, on her way to the Undying Lands, has a vision of her son by Aragorn and convinces Elrond to reforge the sword Narsil that cut the Ring from Sauron's finger at the Last Alliance. Sam overhears Gollum's treacherous plans to murder them and take the Ring for himself, but Frodo does not believe him. Gollum plays on this, trying to turn Frodo and Sam against each other.
Gandalf and Pippin arrive at Minas Tirith to find the steward Denethor mourning his son Boromir, and Pippin swears loyalty to him, as Boromir had saved his life at Amon Hen. Gandalf warns Denethor that Sauron is now ready to strike and urges him to call Rohan for aid. Denethor declines, fearing Aragorn and Gandalf plan to depose him. That night, Gandalf and Pippin witness a pillar of green fire rise from Minas Morgul, where the Witch-king of Angmar sends off his army, heralding the start of the war. Frodo, Sam and Gollum begin climbing the Cirith Ungol stairway. The Morgul army, led by the Nazgûl, drives the Gondorians out of Osgiliath. Denethor orders his youngest son Faramir out on a doomed ride to reclaim the city. Faramir and his knights are apparently killed by the masses of Orcs waiting in the ruined city. Meanwhile, Gollum persuades Frodo to send Sam home on the belief he wants the Ring. Back in Minas Tirith, Pippin has begun the long line of beacon signals to Edoras, where Théoden and Aragorn lead the Rohirrim to Dunharrow to prepare for battle. At Dunharrow, Legolas tells Gimli of the legend of the haunted mountain Dwimorberg, which overlooks the camp, as Éomer says 'that mountain is evil'. Aragorn also meets Elrond, who informs him that Arwen is dying and her "fate is now tied to the fate of the Ring" and warns him they are outnumbered by Sauron's army. He also warns him of a fleet of Corsair Ships, that are arriving in Minas Tirith secretly from the south. Elrond presents Aragorn with the newly reforged Andúril and tells him to brave the Paths of the Dead, where he may acquire the help of the cursed Army of the Dead, who owe allegiance to the Heir of Isildur. Éowyn tries to convince him not to go, confessing her love for him, but Aragorn, knowing that Arwen has sacrificed her immortality to be with him, wishes her well and bids her goodbye. Together with Legolas and Gimli, Aragorn ventures into the Paths of the Dead and meets the Army of the Dead at Dunharrow. Aragorn gains the loyalty of the King of the Dead and his men by brandishing the sword Andúril, proving himself as the heir of Isildur. The trio then capture the ships of the Corsairs of Umbar, who Sauron had intended to launch a surprise attack on Minas Tirith. At Dunharrow, Théoden rides off to war with over 6,000 Riders, unaware Éowyn and Merry are part of the army too.
The Morgul army begins the siege of Minas Tirith, and many missiles are traded between Orc catapults and Gondorian trebuchets, while the Witch-king and the other Nazgûl on their Fell Beasts wreak havoc on the city. That night, they break into the city using the enormous battering ram Grond, and the defenders are forced to retreat as legions of Orcs and Trolls swarm into the city. Gollum, meanwhile, betrays Frodo to the monstrous spider Shelob, but Sam returns to fight her off. Sam believes Frodo is dead and takes the One Ring, planning to complete the quest, but when Orcs from the Tower of Cirith Ungol take Frodo, he overhears that he is still alive. At Minas Tirith, Denethor falls into madness and prepares a pyre for him and the unconscious Faramir. Pippin warns Gandalf and together, they save Faramir, though Denethor commits suicide by self-immolation. With much of the lower city aflame, Orcs advancing, and mounting casualties, the Gondorians appear to be finished. As the sun rises, however, Théoden and the Rohirrim arrive and charge into the Orcs, and the Battle of the Pelennor Fields ensues. As the Orcs retreat away from Minas Tirith, Haradrim reinforcements, including huge numbers of Mûmakil and the Witch-king, arrive to reinforce them. The Rohirrim fight bravely in the face of the Haradrim and Orcs, but risk being destroyed before the Gondorians can move out from the city and aid them. During the assault, the Witch-king swoops down upon Théoden, crushing him underneath his horse. Meanwhile, the Rohirrim are facing significant losses at the hands of the Mûmakil when Aragorn, Legolas, Gimli, and the Dead finally arrive on the captured Corsair ships and counter-attack, routing the Orcs and Mûmakil, while Éowyn and Merry kill the Witch-king. The Gondorians fighting in Minas Tirith are freed, and the Rohirrim are able to escape annihilation. Théoden dies, and Aragorn holds the Dead Army's oath fulfilled, freeing them from their curse.
Sam rescues Frodo from the tower, mostly empty following a fight amongst the Orc garrison over the mithril shirt, and they begin the journey to Mount Doom. Gandalf realises that over 10,000 Orcs stand on the road between Cirith Ungol and Mount Doom, that would make Frodo's journey impossible. Aragorn leads all the men who survived the battle to the Black Gate to distract Sauron and to call out his armies. Sam carries Frodo up to Mount Doom but Gollum attacks them, just as the Men of the West furiously battle the Orcs. Frodo, at the Crack of Doom, succumbs to the Ring's power. Gollum, who been following them, attacks Frodo and bites off his finger, seizing the Ring for himself. Frodo attacks him, and they both fall over the cliff; Frodo grabs the ledge just in time, but Gollum falls into the lava below, along with the ring. The tower of Barad-dûr collapses, and Sauron disappears. The destruction of his form creates an immense shockwave that kills most of the Orcs; the rest perish as the whole of Mordor collapses into a gaping chasm, leaving the men of the West unharmed.
Frodo and Sam are stranded until Gandalf arrives with the Eagles, and they awake in Minas Tirith, finally reuniting with their friends. Aragorn is crowned King, heralding the new age of peace, and is reunited with Arwen. When Aragorn meets the hobbits who bow before him, he stops them and says "You bow to no one". He and the whole of Minas Tirith bow to the Hobbits in honour of their heroics. The hobbits return home to the Shire, where Sam marries his childhood sweetheart, Rosie Cotton. Frodo, however, is traumatized by the effects of the Ring, and leaves Middle-earth with Gandalf, Bilbo, Elrond, Celeborn and Galadriel at the Grey Havens, leaving his account of the story to Sam. Frodo bids goodbye to his friends before boarding the ship, smiling, as the ship sets sail for The Undying Lands. The three remaining hobbits head back to the Shire and Sam is seen greeted by Rosie and his eldest daughter, Elanor. He says the film's final line — "Well, I'm back".