Many years before The Hobbit, the great Dwarven kingdom of the Lonely Mountain, Erebor, ruled by King Thrór, is overtaken with all its treasure by the evil dragon Smaug, and the dwarves of the mountain are robbed of their homeland.

60 years later, a peaceful hobbit of the Shire, Bilbo Baggins is visited by the great wizard Gandalf and a company of thirteen dwarves- Balin, Dwalin, Óin, Glóin, Bifur, Bofur, Bombur, Kíli, Fíli, Ori, Nori, Dori, and Thorin Oakenshield, grandson of Thror and heir to the throne of the mountain. They have a plot to retake Erebor from Smaug, and want to hire Bilbo as their burglar (as Gandalf states that hobbits are light on their feet and have chance to be unnoticed by the dragon). Though first feeling uneasy, Bilbo reluctantly agrees, and the company starts it's journey from Bilbo's hobbit-hole, Bag End.

As they travel through the Shire, Balin tells Bilbo the story of Thorin, where he, Thorin, and Dwalin fought Azog at the Battle of Azanulbizar, where Thror, Thorin's grandfather, was slain by Azog, the pale Orc, whom Thorin duelled and defeated, severing his hand and bringing victory to the dwarf people, reconquering Moria. However, many of the dwarves had died during the battle, and with Thorin's father missing, Thorin became the new King of the Dwarves under the Mountain. One night the company encounters three hungry trolls, Tom, Bert and William, who capture Bilbo and the dwarves (Gandalf dissapears that night), and try to eat them. However, Bilbo manages to play for time long enough for Gandalf to arrive at dawn, when the sun shines on the trolls, turning them to stone. Once free, the company finds the trolls' cave, where they get swords- Thorin claims Orcrist, the Goblin-cleaver, Gandalf finds Glamdring, the Foe-hammer, and Bilbo gets Sting, a small elvish sword, which glows blue if orcs or goblins are near. Bilbo and the dwarves then meet Radagast the Brown, a queer wizard living in Mirkwood- he gives Gandalf a Morgul-blade, which he believes belongs to the Witch-King of Angmar, and he found in the old fortress, Dol Guldur. He also tells Gandalf that he thinks the Dark Lord Sauron is emerging again. Fleeing orc-riders led by the vile Yazneg, who they escape with the help of Radagast, the company eventually reaches the hidden valley of Imladris, also known as Rivendell, the Last Homely House east of the Sea.

There, they achieve a warm welcome from Elrond, the wise elven lord of Rivendell. They are given food (which they do not enjoy) and shelter, and Elrond also helps them by discovering a riddle on their old map of Erebor, which reveals the location of the hidden door that leads into the mountain. As Bilbo and the dwarves unexpectedly leave Rivendell and start their long and dangerous journey through the Misty Mountains, Gandalf shows the White Council, a council of elven rulers and wizards, the Morgul blade and Radagasts' suspicion that Sauron is regaining power, but Saruman, leader of the council, ignores his statements. Meanwhile, it is revealed that Azog, a brutal orc enemy of Thorin, who was thought to be dead, was the one who sent the orcs to kill them. He kills Yazneg for his mistake and places a bounty on Thorin's head.

Meanwhile, Bilbo and the dwarves, fleeing from aggressive stone-giants, are captured by evil goblins of Goblin Town in the mountains. Bilbo accidentally falls into a hole while fighting with a goblin, but the dwarves are brought before the Great Goblin, the tyrannical ruler of Goblin Town. He first attempts to give the company to Azog and his minions for the bounty, but when seeing Thorin's sword, the Goblin-cleaver, he is drove into such a rage, that he orders the execution of the dwarves. However, Gandalf arrives in the nick of time, frees the dwarves and they all escape Goblin Town after a cat-and-mouse chase, with Gandalf killing the Great Goblin.

Meanwhile, Bilbo finds himself on the shore of an underground lake, and finds a golden ring, not knowing that it is actually the great One Ring itself. He then encounters a strange, slimy creature called Gollum. Gollum wants to eat Bilbo, while Bilbo wants Gollum to help him find his way out. So the two start a riddle game- if Gollum wins, he eats Bilbo, but if the hobbit wins, he shows him the way out. As Bilbo is about to ask his final riddle, he suddenly doesn't remember any. He puts his hand in his pocket, and, finding the ring, asks himself- "What have I got in my pocket?". Gollum thinks it is a riddle and cannot answer- he thus loses the game. However, Gollum then discovers that he has lost his precious- the ring Bilbo had found. Realizing that Bilbo took it, he attacks the poor hobbit, who accidentally puts on the Ring, and finds that it makes him invisible. Following an outraged Gollum to the gate of the mountain, he jumps over the wretched creature (not killing him out of pity), and escapes the mountain.

Soon he is reunited with Gandalf and the dwarves, who have escaped from the mountain as well. However, just when becoming relieved of passing over the Misty Mountains, the company is attacked by Azog and his orc soldiers, riding on wargs, evil wolf-like beasts. They climb on trees to save themselves, throwing flaming pine-cones at the wargs. As the trees collapse under the weight of the dwarves, Thorin duels Azog to save the company. He is defeated but saved by Bilbo. With the wargs about to kill them, the great eagles arrive and save the company from the evil orcs, carrying them away to safety. They are put down on a huge rock, the Carrock, at the edge of their next peril- Mirkwood.

After climbing down the Carrock, Thorin's company encounters the bear form of a charging skin-changer named Beorn. Gandalf urges the company to seek refuge in a nearby house, which happens to be the abode of Beorn's human-form. After admitting hating Orcs more than he does Dwarves, Beorn loans his horses to the company so that they can outrun the pursuing Orcs.

Meanwhile, Azog, the leader of the Orcs, is summoned to Dol Guldur where he is given command of an orc army. He then gives his son, Bolg, the task of hunting the dwarves.

Gandalf departs before the others enter the forest of Mirkwood, urging Bilbo and the dwarves to follow the path and to wait for him before entering the mountain. After losing their way in the forest, the dwarves are captured by giant spiders. Bilbo, with the help of the One Ring, manages to free them from the webs of the spiders. However, while fighting the attacking spiders, the dwarves are captured by the Wood-elves.

Later, Tauriel, a female elf, becomes enamoured with Kíli, evoking feelings of jealousy within Legolas, the son of the Elvenking, Thranduil.

Under the cloak of his ring, Bilbo steals the keys and helps the dwarves to escape from the Elf Kingdom using empty wine barrels that float down the river. Along the way, they are attacked by the Orcs lead by Bolg, who had been lying in wait. While trying to open the river gate, Kíli is injured by a poisoned orc arrow, fired by Bolg.

Shortly after, Bilbo and the company meet Bard, a bowman and descendant of the original Lord of Dale, who was waiting to collect the empty barrels in his river barge. Pooling their coins to bribe Bard to smuggle them inside Lake-town, the company is eventually captured by the Master of the Town when they try to steal battle-worthy weaponry. After Thorin convinces the townfolk and Master that they will share the riches of the recaptured mountain, the adventurers receive a grand send-off. Óin, Fíli, and Bofur stay behind to attempt to heal Kíli.

Meanwhile, the Elvenking learns from a captured orc that the dark lord has returned, and so decides to seal off the Elf Kingdom to protect it from the impending evil. However, Tauriel leaves to help the injured Kíli and a concerned Legolas gives chase.

At the Lonley Mountain, Bilbo deciphers the Last Light of Durin's Day clue and uses the moonlight to find the hidden keyhole that opens the secret door into the mountain. After entering, Bilbo attempts to steal the Arkenstone by himself, but is discovered by the awakened dragon, Smaug.

Gandalf, after sending Radagast away with a message for Galadriel, knowingly steps into the orc-ambushed Dol Guldur and engages the Necromancer in a fierce battle that ends with Gandalf's capture.

Bard and his son leave to hide the last Black Arrow; the only thing that can kill Smaug. But Bard is arrested while his son still finds a place to hide the arrow. But at Bard's house, Óin, Fíli, Bofur and Bard's daughters are attacked by Bolg and the orcs. The elf pair of Legolas and Tauriel arrive in the nick of time to fight off the attacking orcs before splitting up: Tauriel stays with Óin, Fíli, and Bofur to attend to Kíli, while Legolas chases after Bolg and the retreating orcs.

Eventually, the dwarves enter the mountain to rescue Bilbo. Tricking the fire-breathing Smaug into rekindling the forge using his his own flames, they attempt to kill the dragon by drowning him in molten gold. However, Smaug stumbles out of the mountain and takes to the air, shaking off the gold-coating. Bilbo watches in horror as Smaug flies toward Lake-Town to wreak havoc and to seek revenge.