To many people he was known as Gandalf (the Grey). He was also known as Mithrandir, the Grey Pilgrim to the Elves and Men of Gondor. He was also known as Incánus in the south and as Tharkûn to the Dwarves.
Gandalf was a Maia, a follower of the Vala Manwë. In Valinor he had been known by the name Olórin. He was sent to Middle-earth as one of the five Istari, Maiar bound in the physical form of old human men, to resist the evil of Sauron. Gandalf arrived at the Grey Havens sometime in the 11th century of the Third Age where Círdan, the ord over the havens, gave him the Ring Narya. He traveled all over Middle-earth to the free peoples, watching and listening, and inspiring and guiding the people he met to realize their potential and further the cause for good.
Gandalf was the driving force behind the Quest of Erebor in T.A. 2941, which is told in The Hobbit. The Lonely Mountain was liberated from the dragon Smaug, Smaug was slain, and the Dwarves returned to Erebor under the rule of a new King under the Mountain. He, along with the White Council were also responsible for removing Sauron from southern Mirkwood in his guise as "the Necromancer."
After these events he had become suspicious about the ring Bilbo Baggins had found. In the time that followed, he researched about the whereabouts of the One Ring, found and questioned Gollum, and was generally very busy in the years leading up to the War of the Ring. Gandalf sent Frodo Baggins on his quest, told in the The Lord of the Rings. After he was separated from the Fellowship in Moria, he died after fighting the Balrog. He was sent back, now Gandalf the White, to further guide the peoples of Middle-earth in their struggles. At the conclusion of the War of the Ring he accompanied Frodo, Bilbo, Elrond, and Galadriel on a sea voyage to the Undying Lands in the West.