Gandalf was based on Odin and LoTRs has a lot of Norse pagan lore woven into it which is why neopagans get a hard-on for it.
It must be remembered that Tolkien was a linguist before he was an author, he spent a long time studying runes and the stories they told. But as has been mentioned already he was a devout Christian and that too colored his writings.
Fortunately his distaste for hard allegory made it possible to please both.
This post was edited by its author on .