Gandalf, also known as Gandalf the Grey and later Gandalf the White, is one of the main characters in The Hobbit and a main character in The Lord of the Rings.
Portrayed by Ian McKellen ands based on the character of the same name
Gandalf is created with the name Olorin and is one of the Istari/Maiar, those who were chosen to be Valar's messengers. Sometime during the Third Age, Gandalf voices his opinion of being sent there and is scared of Sauron. However, after he talks with Manwë understanding, he takes on the name "Gandalf" and arrives at Middle-Earth as the second wizard there. While first getting there, he had been given Narya the Ring of Fire. He befriends many individuals of the country, one of which include Lady Galadriel and Thráin, Thorin's father.
Gandalf becomes one of the White Council members, while he and the group are betrayed by Saruman eventually (The Fellowship of the Ring, An Unexpected Journey)
At some point, Gandalf meets Thráin before the Battle of Moria and presures him to take back the Mountain from Smaug and reclaim the Arkenstone. However, Thráin refuses, and instead entrusts his father' s map and key to Gandalf for safe keeping. Eventually, Gandalf overhears news of Thráin's disappears him and believes him for dead.
Gandalf develops a strong friendship with the Old Took, the grandfather of Bilbo Baggins. He was known to have set off fireworks on Mid-summer's eve and Gandalf became well acquainted with Bilbo's mother and father, and Bilbo himself. (An Unexpected Journey, The Desolation of Smaug)
For more info, see Gandalf's information at The Hobbit-LOTR Wiki