Gandalf as a Maia (named Olórin) before leaving the Undying Lands.
Originally called Olórin , he was accounted as the wisest of the Maiar (with the possible exception of Melian). He was a Maia of Manwë and Varda. He also served under two other Valar, such as Irmo and Nienna. When the Valar decided to send the order of the Istari (also known as Wizards) to Middle-earth, to counsel and assist all those in Middle-earth who opposed the Dark Lord Sauron, Manwë and Varda decided to include Olórin among the five who were sent.
At first, Olórin was nervous and described himself as too weak and too afraid of Sauron. Manwë understood, and told him that that was one main reason why he should go, to overcome that fear. Thus, he insisted that Olórin should go as the third, but Varda convinced him not to include Olórin as the third, but as the second. Olórin agreed, and prepared for his departure from the Undying Lands with the other four wizards.

Arrival in Middle-earth.
When he arrived to Middle-earth, he received Narya, the ring of fire, from Círdan the Shipwright. Olórin, renamed Gandalf , spent many centuries walking among the elves as a stranger, learning from them and teaching them. He later revealed himself as one of the Istari, and eventually became known as the wisest of and most powerful of that order. He joined the White Council, which was formed to investigate a dark power in Dol Guldur, of which Galadriel wanted him to become the leader, yet Saruman came to lead the Council instead of him. Although Saruman was initially more powerful and more knowledgeable about many matters regarding Sauron and the Rings of Power, and was head of the White Council before the War of the Ring, he later grew jealous and afraid of Gandalf, [2] which was the reason of his betrayal.