In January, T.A. 3019, the Fellowship of the Ring travelled through Moria on the way to Mount Doom. They were attacked in the Chamber of Mazarbul by Orcs. The Fellowship fled through a side door, but when the wizard Gandalf the Grey tried to place a "shutting spell" on the door to block the pursuit behind them, the Balrog entered the chamber on the other side and cast a counterspell. Gandalf spoke a word of command to stay the door, but the door shattered and the chamber collapsed. Gandalf was severely weakened by this encounter. The company fled with him, but the Orcs and the Balrog, taking a different route, caught up with them at the bridge of Khazad-dûm. The Elf Legolas instantly recognized the Balrog and Gandalf tried to hold the bridge against it. Since Gandalf and the Balrog were both Maiar, they were beings of the same order. As they faced each other, Gandalf broke the Bridge beneath the Balrog, but as the Balrog fell it wrapped its whip around Gandalf's knees, dragging him to the brink. As the Fellowship looked in horror, Gandalf cried "Fly, you fools!" and fell.
After the long fall, the two landed in a subterranean lake, which extinguished the flames of the Balrog's body; however it remained "a thing of slime, stronger than a strangling snake." They fought in the water, with the Balrog clutching at Gandalf to strangle him, and Gandalf hewing the Balrog with his sword, until finally the Balrog fled into ancient tunnels of unknown origin. Gandalf pursued the creature for eight days, until they climbed to the peak of Zirakzigil, where the Balrog was forced to turn and fight once again, its body erupting into new flames. Here they fought for two days and nights. In the end, the Balrog was defeated and cast down, breaking the mountainside where it fell. Gandalf himself died following this ordeal; but he was later sent back by Eru to Middle-earth with even greater powers as Gandalf the White "until his task was finished." Tolkien does not discuss the ultimate fate of the Balrog.