Gandalf leads Aragorn, Legolas, Gimli, and King Théoden to Isengard where they reunite with Merry and Pippin, who helped the Ents destroy Saruman’s forces. With Saruman himself defeated, Gandalf retrieves Saruman’s palantír which is viewed by a curious Pippin, allowing Sauron to attack the Hobbit’s mind. Gandalf deduces Sauron will attack Gondor’s capital Minas Tirith, riding there with Pippin. They meet Lord Denethor, steward of Gondor, and Boromir’s father. Pippin declares his service to Denethor after Boromir died protecting him.
Approaching his 111th birthday, the hobbit Bilbo Baggins begins writing down the full story of his adventure 60 years earlier for the benefit of his nephew Frodo. This connects The Hobbit with The Lord of the Rings movie 10 years earlier which had a similar scene. Long before Bilbo's involvement, the Dwarf king Thrór brings an era of prosperity for his kin under the Lonely Mountain, far to the East, until the arrival of the dragon Smaug. Destroying the nearby town of Dale, Smaug drives the Dwarves out of their mountain and takes their hoard of gold. Thrór's grandson Thorin sees King Thranduil and his Wood-elves on a nearby hillside, and is dismayed when they take their leave rather than aid his people, resulting in Thorin's everlasting hatred of Elves.
Thorin and his company are being pursued by Azog and his Orc party following the events of the previous film. They are ushered along by Gandalf to the nearby home of Beorn, a skin-changer who can take the form of the bear. That night, Azog is summoned to Dol Guldur by the Necromancer, who commands him to marshal his forces for war. Azog then delegates the hunt for Thorin to his son Bolg. The following day, Beorn escorts the company to the borders of Mirkwood, where Gandalf discovers Black Speech imprinted on an old ruin. This coincides with a telepathic message from Galadriel urging him to investigate the tombs of the Nazgûl. He warns the company to remain on the path and leaves them. Upon entering the forest they lose their way and are ensnared by giant spiders. Bilbo then sets about freeing the dwarves with the help of his recently acquired invisibility ring. He subsequently drops the Ring and first begins to understand its dark influence after he brutally kills a centipede-like creature to retrieve it.
Bilbo and the Dwarves watch from the Lonely Mountain as the dragon Smaug sets Laketown ablaze, and its people flee. Bard the Bowman breaks out of prison, and eventually kills Smaug with the black arrow brought to him by his son Bain. Smaug's falling body crushes the fleeing Master of Laketown, who was escaping Laketown on a boat laden with the town's gold. Bard reluctantly becomes the new leader of the Laketown people as they seek refuge in the ruins of Dale, while Legolas travels to investigate Mount Gundabad with Tauriel. Thorin, now struck with "dragon sickness" over the vast treasure in the mountain, searches obsessively for the Arkenstone, which Bilbo had previously found but kept hidden. Thorin, hearing that people have come to Dale, orders the entrance of the Lonely Mountain sealed off.
Frodo Baggins and Samwise Gamgee continue their journey to Mordor to destroy the One Ring by throwing it into Mount Doom. They are attacked in the night by Gollum, former owner of the Ring, but they capture him. Sympathising with Gollum for their shared burden, Frodo asks Gollum to lead them safely to Mordor, despite Sam’s objections. Meanwhile, Aragorn, Legolas, and Gimli pursue the Uruk-hai who kidnapped their friends Merry and Pippin. The Uruk-hai are slaughtered by the Rohirrim army of Rohan, but the two Hobbits escape into Fangorn Forest where they meet the Ent Treebeard. Aragorn’s group later meet the Rohirrim who have been banished by their king Théoden, who is manipulated by Saruman’s servant Grima Wormtongue. Tracking the Hobbits in Fangorn, Aragorn’s group encounter a resurrected Gandalf who perished in Moria, but was revived to help save Middle Earth.
In the Second Age of Middle Earth, the Dark Lord Sauron forges the One Ring in Mount Doom to conquer all. An alliance of men and elves battle Sauron’s forces in Mordor, where Isildur kills Sauron by chopping off the hand wearing the One Ring. Sauron's spirit survives within the ring and corrupts Isildur so that he keeps it instead of destroying it. This decision leads to Isildur's being killed by Orcs, and the ring is lost in the river Anduin for 2500 years. It comes into the possession of Sméagol who is consumed by its power and becomes Gollum. After 500 years the ring abandons him, to be discovered by a Hobbit named Bilbo Baggins.
Early in the Second Age of Middle-earth, elven smiths forge nine Rings of Power for mortal men, seven for the Dwarf-Lords, and three for the Elf-Kings. Soon after, the Dark Lord Sauron makes the One Ring. Following the Last Alliance of Elves and Men's fall, the Ring is seized by Prince Isildur; and after Isildur was killed by orcs, the Ring lies at the bottom of the river Anduin for over 2500 years. Over time, Sauron captures the Nine Rings and creates the Ringwraiths. The One Ring is discovered by Déagol, whose friend, Sméagol, kills him and becomes Gollum (Peter Woodthorpe). Hundreds of years later, Bilbo Baggins (Norman Bird) acquires it from him.
During the 129th birthday celebration for Bilbo Baggins in Rivendell, Frodo begins his story with Samwise Gamgee, his friend and companion, treading through Mordor as Ring-bearer in Frodo's absence, when Frodo is captive in the orc' fortress of Cirith Ungol. During his journey, Sam ponders claiming the Ring himself; but rejects the idea and rescues Frodo.
In the late Third Age, Sauron's power is increasing, and he has sent his orcs to seek out the remnants of the bloodline of Elendil, kept alive in the Dúnedain. Dirhael, his wife Ivorwen and their daughter Gilraen are fleeing from an attack on their village when they are ambushed by Orcs on a forest road, and saved by a group of rangers led by Arathorn. Not having any place safer to go, the refugees go with Arathorn to Taurdal, the village led by his father and Chieftain of the Dúnedain, Arador. While there, Arathorn and Arador ponder the orcs' motives after finding various pieces of jewelry on their bodies. During her stay in Taurdal, Gilraen falls in love with Arathorn.
The film is set during the timespan of The Fellowship of the Ring. It takes place 17 years after Bilbo Baggins's 111th birthday party and just before Frodo Baggins leaves the Shire for Rivendell (an interval which was not outlined in the motion picture based on that story). The wizard Gandalf fears that Gollum may reveal information about the One Ring to the Dark Lord Sauron, and sends the Ranger Aragorn, heir of Isildur, on a quest to find him.
"Lord of the Beans" begins with the arrival of Randalf in the Shire for Billboy Baggypants' 122nd birthday party (which he calls his "Twelfety-twoth" birthday, referencing Bilbo's "eleventy-first" birthday in The Fellowship of the Ring). Billboy talks about retiring and leaving the Shire and uses a strange bean to produce a birthday cake. Returning to his home, he finds Randalf waiting in his living room. Randalf remarks on Billboy's impressive height, his fine clothing, and his luxuriously appointed home, knowing they have come from the bean, and warns his friend of using such things lightly. Billboy concedes that the bean has given him almost everything he could want. He then announces that he is leaving the Shire and bequeathing everything he owns, including the bean, to his nephew Toto.
The plot of the animated production is in most respects similar to that of the book, which was already styled as a classic children's novel, and so is adapted in that vein for a younger audience; but certain plot points are significantly compressed due to the time limitations of the format. In addition, certain scenes are obviously edited for commercial breaks. In general, alterations include simple omission of additional detail, as the producers expressed their desire to adhere to the written text, including lyrics adapted from the songs in the book but in much longer and greater format.