He rescued the dwarfs twice. After the dwarfs were captured by giant Spiders he threw rocks at the spiders, called them names, and led them away from where the dwarfs were hanging in cocoons waiting to be sucked dry. After the spiders were gone, he put on his magic ring, tippytoed back to the dwarfs and used his sword, Sting, to cut them loose and then led them away, sick and dizzy as they were, to safety. Soon after that they were captured again, this time by the elves. Bilbo hung around the elven stronghold long enough to find out where they all were being held and who had the keys. One night, during a feast, the guard with the keys got drunk and passed out. Bilbo took the keys and let the dwarfs out of their prisons, then took the keys back to save the guard from getting in too much trouble. He packed the dwarfs in barrels and casks from the elf warehouse and they were dumped into the river by workmen to be floated down river to the human town. The barrels were formed into rafts by the elves and floated to the town, where Bilbo unpacked everybody at night while the elves had dinner, and they were safe again.
Chat with our AI personalities
Bilbo rescues the dwarves from the spiders and from the dungeons of the elf king. He threw rocks and used his knife to drive off the spiders and cut them free. He stole the keys and unlocked the dungeons before putting the dwarves into barrels and floating them to freedom. And he gets them too close the door just before Smaug destroys the side of the mountain.
There were a few different occasions that Bilbo saved the dwarfs. One of these times in when they were captured by trolls, and were being cooked. Bilbo convinced the trolls that the dwarfs were ridden with disease, and stalled for enough time that they could be rescued.
Bilbo uses the ring to become invisible. He taunts the spiders until they chase his voice away from the dwarves. He doubled back and freed them.
The dwarves are Bilbo's friends for most of the Hobbit.
Bilbo becomes very fierce when he kills the spider who was trying to capture him. This leads him to rescue the dwarves by killing many spiders and leading them away. He becomes the dwarves leader, and they follow.
Bilbo was completely enchanted by the dwarves' music the first time they played (and sang) for him.
Bilbo stays invisible for weeks listening to conversations of the Wood-Elves. The king's first man<-? and a guard test some wine in the basement of the Wood-Elf compound. They fall asleep and Bilbo steals the guard's keys. Bilbo unlocks the cells of the dwarves and he puts them in empty tubs that the Wood-Elves were about to throw out through their river disposal system, (I can't quite remember what it was called), and the elves who throw out the tubs threw out the dwarves without even looking in them. Bilbo had one problem though, he wasn't in a tub, so he had to grab on to a barrel and float into the lake where the dwarves and Bilbo are accepted and fed and housed.
Yes, in chapter 9 the dwarves (but not Bilbo) were imprisoned by the Wood-elves in Mirkwood forest.