In origin a Maia of Manwë and Varda, Gandalf came to the northwest of Middle-earth after a thousand years of the Third Age had passed, with four others of his order. At the Grey Havens, Círdan entrusted him with the Red Ring, Narya, to aid him in contesting the will of Sauron.
Gandalf wandered widely in Middle-earth, and learned much of its races and peoples. Unlike his fellow Wizards Saruman and Radagast, he never settled in a single place. He was instrumental in the victory of the War of the Ring, but during that conflict he battled with a Balrog, and though he was ultimately victorious, his spirit left his body, but was sent back to Middle-earth to complete his task.
: : :
'Mithrandir we called him in elf-fashion,' said Faramir, 'and he was content. "Many are my names in many countries,", he said. "Mithrandir among the Elves, Tharkûn to the Dwarves; Olórin I was in my youth in the West that is forgotten, in the South Incánus, in the North Gandalf; to the East I go not." - The Lord of the Rings: The Two Towers