Gandalf is a Maia in J.R.R. Tolkien’s Middle-earth legendarium.
The Maiar are powerful spiritual beings who existed before the shaping of the world. Gandalf’s original name is Olórin, and he served the Valar in the Undying Lands before being sent to Middle-earth as one of the Istari, or Wizards. His mission was to oppose Sauron by guiding and encouraging the peoples of Middle-earth rather than ruling them by force.
In The Lord of the Rings, Gandalf appears as an elderly wizard, but his physical form is a chosen limitation. After confronting the Balrog on the Bridge of Khazad-dûm, he returns as Gandalf the White, replacing Saruman as the chief of the Istari.
A frequent mistake is calling Gandalf a Vala. The Valar are the greater divine powers, while the Maiar are lesser but still immensely potent spirits; Sauron and Saruman are also Maiar.