He is a Maiar, a lesser god-like being, the same as Sauron but less powerful. His original name (in the Havens) is Olorin, and he and 4 other Maiar are sent to M.E. by the Valar to oppose Sauron. They are known in M.E. as the Istari, or the wizards. There was Saruman, Mithrandir (Gandalf), Radaghast, and the two blue wizards who went east and didn't figure into the tale. Of the five, Mithrandir became the greatest and was always hearkened as most wise. After Sauron fell, he returned West to the Havens. All this info is buried in the Silmarillion. Possibly. Sauron was known to take many forms in the Second Age, some of which were beautiful and beguiling, to corrupt the hearts of the Numenoreans and convince them to violate the ban of the Valar and attempt to set foot in the Havens, where the race of men were forbidden to go.