Prologue: During the preparations for the birthday party at the beginning of The Lord of the Rings: The Fellowship of the Ring, the elderly Bilbo Baggins (Ian Holm) is writing a memoir. He describes the fabulously wealthy dwarven kingdom of Erebor and its relations with the human kingdom of Dale and the wood elves ruled by Thranduil (Lee Pace). The dwarves are ruled by Thror (Jeffrey Thomas), the King under the Mountain, and the neighboring leaders pay homage to Thror.Dwarves, elves, and men prosper. The caves under Erebor (a.k.a. the Lonely Mountain), rich in gold and jewels, are mined for an uncountable horde of wealth. The dwarves find the Arkenstone, their most valued jewel, which Thror displays above his throne. One day Thror's kingdom is attacked by a dragon, Smaug. Smaug destroys much of Dale and makes short work of Erebor's defenses, despite the brave and canny leadership of Thror's grandson Thorin (Richard Armitage). The surviving dwarves flee and Thorin is embittered when their erstwhile ally, the elven king Thranduil, declines to help them. (Previously Thror and his kin had refused to share diamonds mined from the mountain with the elves, which strained the alliance.)The dwarves attempt to reconquer Moria, a dwarven kingdom in the Misty Mountains that's been overrun by evil creatures called orcs. Led by a huge, pale orc called Azog (Manu Bennett), the orc armies repel the dwarves; in the battle, Azog beheads Thror. An enraged Thorin attacks Azog. Losing his shield early in the duel, Thorin uses an oak log to defend himself, earning the nickname "Oakenshield." He disables Azog by severing his arm, leaving him to be pulled away kicking and screaming by some retreating orc soldiers. Thorin's father Thrain is grief-stricken by the loss of his own father, Thror, and goes missing, never to be seen again. (Eventually, off screen, he's taken prisoner by the Necromancer.) Spurred on by the defeat of Azog, the dwarves manage to reclaim their land, albeit at the cost of the majority of their numbers. Thorin is left in charge of what remains of his grandfather's empire, but his people are too few to defend Moria or retake Erebor. With nowhere to go, the dwarves scatter to make their way in the world as miners, smiths, and toymakers.At this point Bilbo, having filled in the history leading up to his own appearance in the narrative, decides to tell his nephew Frodo (Elijah Wood) the whole story of his adventure 60 years earlier.One morning in the Shire, a much younger Bilbo (Martin Freeman) sits smoking outside his front door when along comes a tallish fellow -- not a hobbit -- in a pointed hat and grey cloak. He's the wizard Gandalf the Grey (Ian McKellen), and he's looking to enlist the last member of an expedition that's ready to head off on a quest. Bilbo wants no part of any adventure, but Gandalf has other ideas. As Bilbo sits down to eat the next evening, he's interrupted by a visitor, an imposing dwarf called Dwalin (Graham McTavish) who acts as though he's expected. He wolfs down Bilbo's supper before more dwarves arrive -- Balin (Ken Stott), Bifur (William Kircher), Bofur (James Nesbitt), Bombur (Stephen Hunter), Fili (Dean O'Gorman), Kili (Aidan Turner), Oin (John Callen), Gloin (Peter Hambleton), Nori (Jed Brophy), Dori (Mark Hadlow), and Ori (Adam Brown) -- as well as Gandalf and eventually Thorin Oakenshield. Bilbo's finicky neatness is disrupted as they carry all the food out of the pantry, rearrange the furniture, and sing a silly song to tease the poor hobbit ("Chip the glasses and crack the plates! That's what Bilbo Baggins hates!") before settling down to the business they came to discuss: their quest.The dwarves plan to return to Erebor and reclaim their kingdom and their treasure from the dragon. A 13-member expedition invites bad luck, so they wish to hire a fourteenth member, a burglar -- and Gandalf assures them that Bilbo is a first-rate burglar, or will be when the time comes. Gandalf also says that Bilbo will present a slight advantage to the company when infiltrating Smaug's lair; Smaug is not familiar with the scent of a hobbit and Bilbo will be less detectable to the dragon. Their contract offers Bilbo a 1/14th share of any profits. When Bilbo wakes up in the morning the dwarves have all gone, and deep down he's disappointed he's lost the opportunity of finding an adventure, but he discovers that Thorin has signed the contract. All of a sudden, Bilbo decides to join the group; he catches up with them on the road and is given a pony to ride. His adventure has begun, although he's still set in his comfortable ways, and complains about the pony rub causing him a skin sore, and even tries to return to his hobbit-hole.Thorin and company travel east for some days until one evening, while puzzling over the disappearance of some of their ponies, Bilbo, Fili, and Kili (the two youngest dwarves) see firelight in the distance. They creep closer and discover three large trolls. Bilbo, as the "burglar," is pushed forward to rescue four ponies being kept in a corral. He sneaks in but is captured. The dwarves attack the trolls but are forced to surrender when the trolls threaten to rip Bilbo apart. Half the company are tied to a large rotating spit over the troll's fire, the other half are trapped in large sacks. Bilbo stalls for time by telling the trolls the dwarves are infected. Suddenly Gandalf appears, splits a boulder with his staff, and sunlight pours through the crack, turning the trolls to stone.Realizing that the trolls would have a cave to retreat to in the daytime, they search around and find the hidden lair. Gandalf and the dwarves find some good -- indeed, magical -- elven swords along with a small treasure trove. Gandalf gives the smallest of the swords (later called Sting) to Bilbo, saying it will glow blue when there are orcs and goblins around. The other swords are the famed Glamdring, which Gandalf takes for himself, and its mate, Orcrist, which Gandalf suggests Thorin keep. Thorin is reluctant to use an elven sword but Gandalf persuades him, saying such a fine weapon is a rare find.Later, one of the dwarves reports the ponies have all run off. Radagast the Brown (Sylvester McCoy), the wizard who watches over the region, arrives in his rabbit-drawn sleigh. He tells Gandalf there is evil in the forest and in the old abandoned fortress of Dol Guldur. He recounts a fight with a spirit, the Witch King of Angmar, and gives Gandalf an object wrapped in cloth.The orcs arrive and Radagast, saying he will lead them away, takes off with his rabbit sleigh. The travelling party makes its way across a hilly open area while the orcs chase the brown wizard. However, one orc tracks them down and the fight draws the others. Gandalf leads them into a deep crevice in the rocks before the orcs are driven off by elvish horsemen.Travelling through the cave, the party comes out near Rivendell, home of Elrond (Hugo Weaving). Thorin, who still wants nothing to do with elves, angrily declares this was Gandalf's plan all along. Elrond appears with his riders and greets Gandalf and the dwarves warmly. Gandalf convinces Thorin to show Elrond the map. Elrond notices secret writing on the map that has to be read on the same calendar day during the same phase of the moon as when it was written, which luckily is that night. Blue letters glow on the map under the moonlight. Elrond translates the instructions on how to find the entrance to the Lonely Mountain. The dwarves must be in a certain spot on the mountainside on a certain day in late summer and the setting sun will show the door.Later, Gandalf meets with Saruman (Christopher Lee), Galadriel (Cate Blanchett), and Elrond. They discuss the mysterious Necromancer and some looming portents of evil. Saruman seems indifferent, saying that the evil spirit was vanquished centuries before and couldn't possibly gain enough power to return, much less materialize again. Gandalf produces the object wrapped in cloth that he received from Radagast: an evil sword, a Morgul blade, that was supposed to have been buried deep in a mountain. Galadriel silently promises aid to Gandalf when needed. Meanwhile, the dwarves and Bilbo continue their journey.Climbing a mountain, the party is caught in the midst of a battle as three stone giants come alive and start fighting each other. Bilbo and the dwarves take refuge in a cave. Thorin berates Bilbo again for having to save his life. That night, discouraged, Bilbo prepares to sneak away. Bofur tries to convince him to stay, but Bilbo still feels he isn't prepared for the life of adventure the dwarves are accustomed to. Suddenly, Bilbo's sword glows blue, the floor opens up and the party falls into a crevice and onto a wooden platform, where they are surrounded and taken prisoner by goblins.Bilbo slips away in the confusion but has to fight a lone goblin; the two fall further into the abyss. While the goblins take the dwarves to their king, the Great Goblin (Barry Humphries), Bilbo awakens to see Gollum (Andy Serkis) attacking and killing his unconscious goblin. Gollum drops a gold ring and Bilbo puts it in his pocket. A short time later, Gollum discovers the hobbit and alternately threatens and wheedles as Bilbo points his sword at him. They agree on a contest of riddles: if Bilbo wins, Gollum will show him the way out; if Bilbo loses, Gollum will eat him.Elsewhere in the goblin caves, the king notices the dwarves' swords and recoils from the sight of Orcrist, known to his people as "Goblin Cleaver." He orders the dwarves killed and sends a message to Azog, giving the location of the dwarves. As the goblins move in, there is a sudden white burst and everyone is stunned. Gandalf appears and urges the dwarves to run. They gather their swords and rush down the rickety wooden walkways that traverse the goblins' cavern in an exciting and physics-defying chase.Bilbo and Gollum trade wits and Bilbo has the final riddle; he asks Gollum what he has in his pocket. (It's Gollum's ring). Gollum is enraged (this isn't a standard riddle) and refuses to uphold the deal. Bilbo slips the ring on his finger and is surprised that he has become invisible to Gollum. Gandalf and the dwarves reach the bottom and run past Bilbo and Gollum to escape from the goblin caves. Bilbo has a chance to kill Gollum but relents and just jumps over him. Gollum is further enraged. Bilbo also escapes into the daylight, where the goblins can't immediately follow.The dwarves make it out to a wooded area and try to rest. Gandalf counts heads and notices Bilbo is missing. No one knows where he is and Thorin suspects he ran off -- he has long believed that Bilbo is not up to the task of the adventure and only longs to return to his home. Close by, and still invisible, Bilbo overhears Thorin. He suddenly appears and tells Thorin and his company that he does indeed wish to return home, but he will stay with the dwarves because they have no home of their own. Thorin still seems unimpressed, but the rest of the dwarves are relieved that Bilbo has rejoined them.Without warning, Azog and his warg-riders appear and chase the group to the edge of a cliff, where they all climb trees. But the snarling beasts cut the branches and topple the trees. Gandalf catches a moth, whispers to it, and releases it. When Azog appears on his white warg, Thorin is stunned to see him still alive. Gandalf hurls pine-cone fireballs at the enemy below, and soon the area is in flames and the animals retreat. Cornered, Thorin decides to attack and rushes toward Azog, but is knocked down and seemingly a meal for Azog's mount. Bilbo joins in the counterattack, saving Thorin from death. The other dwarves follow. The orcs are gaining the upper hand when a flock of huge eagles arrives and starts tossing the orcs off the cliff and carrying the dwarves away. (Gandalf sent the moth to get help.) Finally the last tree topples but Gandalf is saved by an eagle. The eagles carry the group to the Carrock, a smaller mountain in the middle of a river that offers them some safety. Thorin revives and is grateful to Bilbo. He apologizes for doubting him, saying he couldn't have been more wrong about Bilbo's bravery in battle. In the distance, Bilbo spots the Lonely Mountain and they all stare in awe, realizing they're that much closer to their home.A thrush flies toward the gates of the old dwarf redoubt and bangs on a nut. Inside, Smaug arouses from a pile of gold coins, opening one eye.