Gandalf is the best-known of the Maiar of the people of Manwë and Varda. He is said to be one of the wisest of that order, rivaling Saruman. He came to Middle-earth in the Third Age as a wizard in order to counsel and assist all those in Middle-earth who opposed Sauron.
In The Hobbit, he arranges and partially accompanies the adventurous quest of Bilbo Baggins and the thirteen Dwarves to regain the treasure of the Lonely Mountain. It is on this quest that he finds his sword, Glamdring.
In The Lord of the Rings, he urges Bilbo to give his magic ring to Frodo, whom he motivates to take the ring and destroy it in Mount Doom. Gandalf is initially unable to accompany Frodo and his servant Sam, but rejoins them in Rivendell as the second half of The Fellowship of the Ring begins. Taking leadership of the fellowship (nine good people "set against the Nine Riders"), he and Aragorn lead the hobbits and their companions on an unsuccessful effort to cross Mount Caradhras in winter. Then they take the "dark and secret way" through the mines of Moria which leads to Gandalf's apparent demise. Gandalf reappears as if born anew in the Ents' forest, when he encounters the Three Walkers (Aragorn, Gimli, and Legolas) who were tracking Merry and Pippin.
Gandalf initially appears as an old man with a gray beard, a gray cloak and a large gray hat. Although some of the Wise know his true nature, others mistake him for a simple conjurer. After fighting the Balrog in the Mines of Moria, he reappears as a more imposing figure clad all in white. The change of color is significant, for he has come to replace the corrupted Saruman as the chief of the Wizards. In a sense he has become Saruman, or rather what Saruman should have been.