Bilbo Baggins is a hobbit who lives in a large, comfortable underground house in the Shire and has no interest in adventures. One day, he encounters Gandalf, a wizard who knew Bilbo’s scandalously adventurous grandfather. Though he's uncomfortable that Gandalf talks about Bilbo joining an adventure, Bilbo invites Gandalf to tea the next day. At tea, Gandalf brings with him thirteen dwarves, lead by Thorin Oakenshield, who are trying to reclaim their ancestral home and treasure under the Lonely Mountain from the dragon Smaug. Gandalf and the dwarves offer Bilbo one-fourteenth of their treasure in return for his serving as their burglar. Bilbo doesn't explicitly consent to this agreement, but he's excited by the dwarves' stories of treasure.
The next day, Gandalf tells Bilbo that he must meet the dwarves at the local tavern; Bilbo rushes there, and finds himself traveling with Gandalf and the dwarves on their quest to the Lonely Mountain. Shortly thereafter, Gandalf goes missing, it starts to rain, and the dwarves see a light in the distance. Bilbo goes to investigate the light, and finds three trolls eating their supper. The trolls catch Bilbo, but he slips free; then, the trolls capture the thirteen dwarves. Gandalf imitates the sounds of the trolls' voices, leading them to fight for so long that the sun rises and turns them to stone. The dwarves free themselves and find two swords. Bilbo finds a large knife that will work as a sword for him, too.
The group rests in the Elven city of Rivendell under the care of the elf-lord Elrond. While there they learn that they will be able to enter a secret passageway in the side of the Lonely Mountain on the first day of the dwarf New Year. They travel through the Misty Mountains, where they are all imprisoned by goblins, except for Gandalf who escapes. Bilbo and the dwarves are taken before the Great Goblin, but Gandalf reappears, slays the Great Goblin, and frees Bilbo and the dwarves. In the ensuing flight from the goblins, Bilbo falls down a cavern and loses consciousness.
Bilbo reawakens in a dark cavern and finds a ring lying on the ground. Not long after he encounters a treacherous creature, Gollum, with whom he holds a riddle-telling competition: if Gollum wins, he eats Bilbo; if Bilbo wins, Gollum shows him the way out. Bilbo wins the competition, but Gollum goes to find his ring, which makes the wearer invisible, so that he can kill Bilbo. When Gollum discovers the ring is missing he is enraged and plans to kill Bilbo. But Bilbo accidentally puts on the ring and realizes that the ring makes him invisible when Gollum, searching for him, ends up rushing right past him. Bilbo follows Gollum out of the cave and eludes goblins to escape from the Misty Mountains.
Bilbo reunites with Gandalf and the dwarves, who are impressed with his talent for deception and concealment. As they travel down from the mountains, they're forced to hide in some trees from some wargs (talking wolves); when a fire breaks out, Gandalf summons the giant eagles, who agree to take the group to the Carrock, where they stay with the shape-shifter Beorn.
Gandalf reveals that he must leave Bilbo and the dwarves as they begin the next stage of their quest through the dangerous Mirkwood forest. Despite Gandalf and Beorn's advice to stay on the path at all costs, Bilbo and the dwarves are lured off the path by the sight of wood-elves eating a feast. When the group is then captured by giant spiders, Bilbo uses his ring to free himself, kill many spiders, and free the dwarves; unfortunately, angry wood-elves capture and imprison them all, except for Bilbo who is still invisible, shortly thereafter. Bilbo uses his ring to free his friends from their cells and transports them out of the forest via barrels, which the elves use to send wine in trade down the river to the human town of Lake-town.
Bilbo and the dwarves arrive in Lake-town, where they're welcomed as heroes who will vanquish the dragon, Smaug, and bring prosperity to the cities of men once again. They travel to the Lonely Mountain, where the last ray of sunshine on the dwarf New Year reveals the keyhole to a secret passageway. Bilbo alone is brave enough to enter the mountain, and manages to sneak into Smaug’s lair and steal a cup from the pile of treasure. Smaug is enraged. Later Bilbo sneaks again into Smaug’s lair, but this time Smaug is only pretending to sleep: Bilbo speaks to Smaug in riddles, saying that he is a barrel-rider and learning in the process that Smaug has a weak point on his belly. Bilbo later gives this information to the dwarves, and to a talking thrush who overhears them. Smaug, during that same conversation, poisons Bilbo’s mind with suspicion that the dwarves will not uphold their promise to give him one-fourteen of the treasure; when he raises his doubts to Thorin, Thorin insists that Bilbo can take whatever fourteenth of the treasure he wants. Bilbo secretly takes the Arkenstone, the most beautiful jewel in the dwarves’ treasure.
Interpreting Bilbo’s self-given name of “barrel-rider” to mean that he has been sent by men, Smaug flies to Lake-town and devastates it. But as he does so, an archer named Bard, a descendant of the Lord of Dale (a city that used to thrive as a hub of trade of dwarven gold and crafts before Smaug arrived), learns from the thrush about Smaug’s weak point, and uses the information to shoot and kill him with a black arrow that had long been in Bard’s family line. News of Smaug’s death spreads across Middle Earth, and the men led by Bard ally with the wood-elves and march to the Lonely Mountain to claim some of the treasure, as repayment for the destruction Smaug leveled against them. Thorin refuses these requests, and it seems fighting between men, elves, and dwarves is imminent. Eager to end this conflict, Bilbo secretly gives the Arkenstone to Bard and the elves; when Bilbo admits what he’s done, Thorin expels him from the Lonely Mountain. Bilbo reunites with Gandalf, who has returned from his other business.
Thorin summons his cousin, Dain, to help him defend their regained city and treasure. At the same time, goblins and wolves ride to the Lonely Mountain, eager to avenge the Great Goblin’s death. Gandalf encourages men, dwarves, and elves to from an alliance, and at the Battle of the Five Armies, they unite against the goblins and wolves, defeating them with the help of Beorn and the Eagles. Bilbo uses his ring to hide during the fight. When he meets up with the survivors of the battle, he finds that Thorin has been fatally wounded. Thorin tells Bilbo that he regrets expelling him. Bilbo returns to hobbit-town with two chests of treasure (having given up the claim to the even larger one-fourteenth that had originally been promised to him), enough to make him a wealthy man. A year later, he’s visited by Gandalf and one of the dwarves, Balin, who tell him that Bard is now the master of Lake-town, goblins have been largely killed off, and dwarves, elves, and men now coexist peacefully.