Tolkien's Lord of the Rings was complex. It was never intended by Tolkien.
Tolkien was a philologist (studied the evolvement of Speech), and as a hobby made up his own language- Language of Elves. He also lamented that England did not have any Mythologies to compare to Norse and Greek Mythologies.
So, he decided to create an elaborate Mythology. He felt it was not publishable. Years later, he made up a bedtime story for his Children, which he wrote down. It was never intended for publication, but was given to a sick friend to read, and through serendipity, came to a publisher. The Hobbit was a hit, and had a fanbase asking for more. The result was a book that took over ten years to write, "Lord of the Rings".
However, instead of making another Children's book. Tolkien decided to tie his new story into his existing mythology of Europe. This was later published as "The Silmarillion" and "Lost Tales".
So, if you want to know about Tolkien's theological Universe, you have to travel back in time to his creation story. He has a god, "Illuvatar", and "The Sacred Fire"- I think akin to the Holy Spirit. Illuvatar created through "Music". And he created several levels of angelic "TYPE" beings. However, they act much more like Norse and Greek gods of mythology.
There is a "Fall". Morgoth, is like a Fallen Angel. But he behaives like a fallen god of mythology. And he creates other malicious creatures, and seduces other "Valar" - higher angels, and some Maiar- Lesser angels. Ungoliant- shelobs ancestor, was one of these.
In Tolkien's world. Wizards are not like Harry Potter Wizards, who learn magic crafts. In Tolkien's worlds, Wizards are actually akin to "weaker angels" who come to earth to help men. They are Istari. (Please forgive spelling errors). So, in one sense, Gandalf was an angel, and he was not allowed to use his powers (fully) because angels were fragile, easily corrupted by their powers. When he became Gandalf "the white"- Illuvatar rewarded him for his faithfulness and sent him back with greater power.
As for "magic". Some was intrinsic, meaning, it was within the nature of the being. Saruman had an innate gift of persuasive speech, to make men do what he desired. But he was a good "mini-angel" Wizard, until he was corrupted by his desire for order, and seduced by the desire to master the ring to impose "His form of order".
It is implied that "magic" is as "magic" is from a mythological perspective where the universe is somewhat magical. By "Craft" Sauron makes a set of rings which enhance people's natural gifts. He gives them to men, elves and dwarves to help them rule more effectively. However, he made a secret master ring, through which he could control the other rings. He used these to enslave men, who became Ringwraiths. However, since the Elves were a part of the creation process, he couldn't do that to the Elves. But when he wore his ring, he could see the Elves, and their plans, and use influence. There were three rings for the Elves. I think one for Fire, Water and Wind??? Gandalf had the ring of Fire, Galadrial the ring of Water. As long as Sauron didn't have his ring, they could still use these rings. Elrond also ended up having a ring.
Harry Potter is more generic, and isn't a "Theological" book. In essense, it's like "Luke Skywalker", in that you are to believe certain people have a "gift". But it doesn't really get "Theological" in the sense of tracing everything to its roots.
If you are into the basic "search" for reason. It's one of those things, where I think people can stay up nights thinking of the meaning of the Universe. Years ago, I had a curiosity about such things. I was an atheist, and my brother had a ton of Pagan literature. But I always asked the "Where's, when's, why's and how's." To me the Universe was scientific. And if there was such a thing as magic, "Which I believed existed at some levels". I was always "Why does it work..." How is it possible to see the future, astral travel, move objects...etc. And I was never satisfied with "magic" as being the answer. In my mind there was always a "cause".
And in my own mind, the theological question of magic always came back to the existence of "more" than what we see here and now. Most people don't care about such things, because all they want to know is "Does it work, or doesn't it work", and are only thinking about the ends, and not the means. But to me, if there was a "more". I always had an assumption, "What is the will of the source?" What does the source get out of this? What does the source want?"
And having read Greek and Norse mythology, the concepts of "gods" was pondered. Are there primary unseen "movers". I always presumed "conjurerers" were never the primary movers, or they would not need craft. And after reading "Search for a soul" and a ton of other books, I became more convinced that there was another "spiritual realm". I call it "spiritual", in the sense that they can exist outside of our awareness, but influence our reality.
And of course, that leads to religious questions in the sense of "Are their good spirits, and evil spirits?" It seemed a fair question since all cultures seemed to have some version of this, and I figured there might be a reason. Whether pantheist, animist, or monotheist, there is good and evil.
So, I was leery of "jumping into" the occult, simply because I wanted to know what the sources were, and what the sources expected. Somehow, I didn't believe the Luke Skywalker, "The force is neither good, nor evil...."
I lived in a world where I believed in evil, before I believed in good. This "search" took place around the time, the movie "The exorcist came out, and the play, "Jesus Christ Superstar"- an agnostic play, came out. I believed the exorcist was based on reality, and was curious.
So, what I did was, I went on a search, to determine if anyone in the world was having first hand supernatural experiences. Did miracles happen today? Do exorcisms happen? Is there actual proof? Are their credible first hand witnesses?-not liars or schizophrenics. Has anyone ever died and come back? What did they see? Who did they speak too?
I went beyond wanting to know what books say, and wanting to know if there was a reality that some religions and beliefs are based on. "Is truth subjective, or is there objective truth?"