The film begins with a flashback set to the first film, with Gandalf the Grey giving his life in battle against the Balrog on the Khazad-dûm, giving the Fellowship of the Ring time to escape from the Mines of Moria. Weeks later, Frodo Baggins and Samwise Gamgee continue their journey to Mordor to destroy the One Ring and, with it, the Dark Lord Sauron. One night, they are attacked by the ring's former owner Gollum. The pair capture Gollum, but Frodo takes pity on him, understanding the burden of the Ring, and he persuades Gollum to guide them to Mordor. Sam immediately distrusts Gollum on sight and warns Frodo that Gollum will betray them.
In Rohan, Aragorn, Legolas and Gimli pursue the Uruk-hai who have taken Meriadoc Brandybuck and Peregrin Took prisoner. Meanwhile, Rohan's King Théoden has been entranced and physically weakened by Gríma Wormtongue, who is secretly in the service of Saruman the White. Saruman has his Orcs and Wild Men of Dunland lay siege to the lands. Théoden's nephew Éomer accuses Gríma of being a spy; Gríma has him banished for undermining him. Éomer travels to the countryside to gather the remaining men of the Rohirrim, and his army later ambushes and kills the group of Uruk-hai and Orcs holding Merry and Pippin. Merry and Pippin flee into Fangorn Forest and meet Treebeard, the oldest of the Ents.
Frodo, Sam and Gollum traverse the Dead Marshes, evading a Nazgûl along the way, but upon reaching the Black Gate, they find it closed and guarded by Orcs. Gollum convinces the pair that he will lead them to an unguarded entrance. After learning of Éomer's ambush, Aragorn, Legolas and Gimli discover Merry and Pippin's trail. The trio are confronted by Gandalf, reborn as Gandalf the White, who joins the trio as they journey to Edoras. After arriving, they free Théoden from Gríma's spell, and inform the king of his son Théodred's death. Théoden moves his people to the stronghold Helm's Deep for safety. Fearing Helm's Deep will not survive, Gandalf leaves to find Éomer. Gríma flees to Orthanc and informs Saruman of a weakness in the outer wall of Helm's Deep, and Saruman dispatches his vast army to the stronghold, with the intent of wiping out all of Rohan and Aragorn with them.
Meanwhile, Gollum struggles with his loyalty to Frodo and his consuming need for the Ring. When Sam and Frodo are captured by Rangers of Ithilien, Frodo reveals Gollum's presence to spare his life; Gollum nevertheless feels betrayed, and begins plotting against Frodo. As Théoden's forces travel to Helm's Deep, they are attacked by Saruman's Warg riders and Aragorn is thrown from a cliff to his apparent death in a raging river. In Rivendell, Elrond convinces his daughter Arwen to abandon her love for Aragorn and leave Middle-earth with her fellow Elves, pointing out that even if Sauron is defeated, Aragorn will still succumb to old age. Meanwhile, Éowyn, Théoden's niece, nurtures a growing affection for Aragorn.
Learning that Frodo has the Ring, the Rangers' captain, Faramir, who is also Boromir's brother, orders that it be sent to Gondor. In Rohan, the barely-alive Aragorn washes up on the river bank. He makes his way to Helm's Deep and warns Théoden that he has seen Saruman's army headed for the fortress. Théoden gathers his men to fight against Saruman's army of Uruk-hai, alongside a battalion of Elves led by Haldir who were sent to re-enforce the men of Rohan. In Fangorn Forest, Merry, Pippin, Treebeard and other Ents hold a council to decide on the role of the Ents in the war with Saruman.
The battle of Helm's Deep begins between the Uruk-hai and Rohirrim with Aragorn and his companions. Explosives are used against the weakness in the wall, allowing the Uruk-hai to breach the fortress, and Haldir is killed. In Fangorn, Treebeard and the other Ents initially refuse to get involved in the war until Pippin shows them that Saruman has decimated the forest in order to fuel his campaign. Enraged, Treebeard leads the Ents in attacking Isengard to exact vengeance on Saruman. Aragorn leads Théoden, Legolas and the remaining Rohirrim to attack the Uruk-hai, allowing the Rohirrim's women and children to escape into the mountains. Gandalf appears, accompanied by Éomer and his large army, and the combined forces cause the Uruk-hai to flee into Fangorn, where the Ents and their Huorn allies destroy them. At Isengard, the Ents defeat the Uruk-hai and break the river dam, drowning the surviving Orc defenders, flooding Isengard, and stranding Saruman in his tower.
Faramir has the Hobbits taken to the war-torn Osgiliath, where they are attacked by Orcs led by a Nazgûl. Frodo succumbs to the Ring's influence, but was saved by Sam. The Nazgûl is defeated and flees. Faramir, understanding the danger of the Ring, frees the Hobbits and sends them on their journey, joined by Gollum. Gandalf remarks that Sauron will seek retribution for Saruman's defeat, stating that hope now rests with Frodo and Sam. At that same moment, Gollum vows to reclaim the Ring by having "her" kill Frodo and Sam.