The creature Gandalf battled in the Mines of Moria was the Balrog. In Tolkien's story, this particular Balrog is known as Durin's Bane, an ancient servant of Morgoth that had hidden beneath the Dwarven kingdom of Khazad-dûm.
The Fellowship encounters it during their desperate passage through Moria in The Fellowship of the Ring. After the creature attacks, Gandalf confronts it on the Bridge of Khazad-dûm and prevents it from pursuing the others. The Balrog pulls Gandalf into the abyss, leading the Fellowship to believe that the wizard has died.
A cave troll also appears during the Moria sequence, but it attacks the Fellowship in the Chamber of Mazarbul and is not Gandalf's main opponent. The Watcher is another separate creature guarding the West-gate entrance, while a ringwraith is one of Sauron's servants and never fights Gandalf in Moria. In Tolkien's lore, Balrogs are corrupted Maiar associated with fire, shadow, and monstrous power.