Gandalf, sometimes gandalf the gray or gandalf the white, is a fictional character in the works of british author, teacher and philologist j. r. r. tolkien.