Thorin Oakenshield 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.
The remaining spiders are fended off by the Wood-elves led by Tauriel and Legolas. They also capture the Dwarves, and bring Thorin before their king Thranduil. Thorin confronts the Elvenking about his neglect of the Dwarves of Erebor following Smaug's attack 60 years earlier, and is consequently imprisoned with the other Dwarves. Bilbo, having avoided capture, arranges an escape using empty wine barrels that are sent downstream. While being pursued by the Wood-elves, they are ambushed by Bolg and his Orc party, and Kíli is wounded with a Morgul shaft. They engage in a running three-way battle down the river, but ultimately the Dwarves are able to escape both groups of pursuers. Thranduil then seals off his kingdom when an Orc captive reveals an evil entity has returned and is amassing an army in the south, but Tauriel decides to leave and assist the Dwarves. Legolas goes after her. Meanwhile, Gandalf and Radagast go to investigate the tombs of the Nazgûl, which they find to be empty.
The company are smuggled into Esgaroth by a bargeman called Bard. Thorin promises the Master and the people of Laketown a share of the mountain's treasure. It is then revealed that Bard is a descendant of the last ruler of Dale, and possesses the last black arrow capable of killing Smaug. Kíli is forced to remain behind, tended to by Fíli, Óin, and Bofur, as the remaining company receive a grand farewell. Meanwhile, Gandalf travels south to the ruins of Dol Guldur, while Radagast leaves to warn Galadriel of their discovery at the tombs of the Nazgûl. Gandalf finds the ruins infested with Orcs and is ambushed by Azog. The Necromancer overpowers and defeats Gandalf and reveals himself as Sauron.
Thorin and his remaining company reach the Lonely Mountain, where Bilbo discovers the hidden entrance. He is sent in to retrieve the Arkenstone, and while doing so, he accidentally awakens Smaug. While trying to find Bilbo, Smaug reveals his knowledge of Sauron's return. Back in Laketown, Bard attempts to bring the black arrow to the town's launcher, as he fears what may happen when the Dwarves enter the mountain. However, he is arrested in the process and leaves his son to hide the arrow. Bolg and his Orc party then infiltrate the town and attack the four Dwarves, but are quickly dispatched following the arrival of Tauriel and Legolas. Tauriel then tends to Kíli. While Kíli is recovering, he openly admires Tauriel's beauty and wonders if she loves him. Legolas leaves in pursuit of Bolg. Meanwhile, Gandalf watches helplessly as Azog and an Orc army march from Dol Guldur towards the Lonely Mountain.
Back inside the mountain, Bilbo and the Dwarves try to rekindle the mountain's forge in an attempt to bury Smaug alive in molten gold. This fails however and Smaug stumbles out of the mountain and flies off to destroy Laketown as Bilbo watches in horror at what they have unleashed, saying to himself, "What have we done?"