Gandalf was an Istar wizard.
For over 2000 years, Gandalf the Grey worked against the rising evil powers in Middle-earth. In TA 2941, Gandalf led a quest to the Lonely Mountain where Smaug the Dragon was slain. During the quest, Gandalf acquired the sword Glamdring and Bilbo Baggins found the One Ring. In TA 3018, Gandalf came to Frodo Baggins and initiated the Quest of the Ring. In Rivendell, he became a member of the Fellowship of the Ring and led his companions through many different perils and adventures.
However, in the Mines of Moria, upon the Bridge of Khazad-dûm, Gandalf faced a Balrog. He claimed to be "A servant of the Secret Fire...wielder of the Flame of Anor." No one knows what he meant by the Flame of Anor. The wizard was pulled from the bridge when he toppled the Balrog from it and appeared (to the Fellowship) to have been slain. This was not the case, and Gandalf slew the Balrog but lost his strength and died.