Chapter 9 is the section of the novel you want to look at. This narrates how, after their escape from the spiders, the Dwarves, exhausted, are captured by the Elves, and taken into the Hall of the Elvenking. Of course, Bilbo has his magic ring on that makes him invisible, so he is able to follow them. He just makes it into the hall with his comrades before "the great gates of the king closed behind them with a clang."
What follows is something of a hiatus in the tale - Bilbo is forced to wonder around invisible, always scared of discovery and trying to work out what to do:
Poor Mr Baggins - it was a weary long time that he lived in that place all alone, and always in hiding, never daring to take off his ring, hardly daring to sleep, even tucked away in the darkest and remotest corners he could find.
He is able to discover Thorin and inform the other dwarves that he is there, but he only finds a "breakthrough" when he discovers the empty barrels that are floated down the river and of course uses this to engineer their escape.