Bilbo encounters Gollum in the cave beneath the Misty Mountains in The Hobbit.
After becoming separated from the dwarves, Bilbo finds a small golden ring and meets Gollum on an underground island. The two play a riddle game, with Bilbo’s question about what he has in his pocket helping him escape. This meeting becomes crucial to the later story of The Lord of the Rings.
In The Hobbit, Gollum is presented as a mysterious underground creature whose behavior is shaped by his possession of the ring. Later versions and the expanded mythology identify him as Sméagol, a former hobbit-like member of the Stoor people who was corrupted by the Ring.
Gollum is sometimes confused with other famous Tolkien creatures. Shelob is a giant spider in Cirith Ungol, while the Balrog is a powerful demon-like being encountered in Moria. Ungoliant is an ancient spider-like entity from The Silmarillion. None of those creatures is Bilbo’s riddle-game opponent.