People upvote this response because that's the correct one and it should be on the very top. Ask Stephen Colbert if you don't believe me. He'd also tell you that Gandalf is Maia. Maiar is the plural form.
Vala/Valar, Ainu/Ainur, Maia/Maiar etc etc. It's important unless you want to forget that Tolkien came up with languages and the setting first and only wrote the stories to see how that would work out.
Now just to expand on it since it also misses the very core of the answer:
Tolkien created his world with very strong links to core Christian concepts (he was an orthodox Catholic) so there is really no "magic" to speak of. The world of MiddleEarth - called "Ea" has been created by the singing of Ainur before time. The creation myth is described in the Silmarillion in part called "Ainulindale".
So the "magic" of Ainur and Maiar is just the ability to influence and change the fabric of this world depending on their innate power as angelic beings because that's what they are supposed to do. Ainur and Maiar are the caretakers of Ea/Arda/MiddleEarth and their "magical" powers are sort of admin privileges. And the privileges have limits - see the curving of Arda and sinking of Numenor - where the mightiest of Valar - Manwe - gave up his stewardship of Arda to Iluvatar for a while because that was above his pay grade.
The Elves and Men have different skills and Elves are more "magical" because they have a different relationship with the world. Elves are immortal and are tied with Arda - that's why they have "magic". Men are mortal and are just passing through the world - which is why they don't. This is why there are Elvish "wizards" like Galadriel or Feanor or Cirdan and why Luthien was said to have incredible power despite never shooting a single fireball out of her ass.
Arda is given to "Children of Iluvatar" - Elves and Men - and Ainur/Maiar are there to ensure that whatever Iluvatar's/Eru plan is goes through. They fight unbelievable wars with Melkor/Morghoth (the original bad guy) but once the first Children of Iluvatar (Elves) wake up they back off. They are not supposed to meddle in it and do it only rarely when there's no other way. Consider that at the end of the first age during the war of the wrath the most powerful being tasked with bringing Morgoth down is Eonwe - a Maia - Manwe's herald. At the time there were a number of Valar who could bitchslap Morgoth at will since he lost a lot of his original power. But that was not their place and job so they sent the least powerful of them who could help the Elves and Men defeat Morgoth. At the same time they could send Tulkas over and the war would be done in a single afternoon because Morgoth was always scared shitless of Tulkas.
Notice that throughout Silmarillion and LoTR it is always Elves and Men fighting evil in the form of Morgoth and later Sauron on their own. Talking about Catholic foundations eh?
This is also why MERP is a terrible RPG system if you ever wanted to play chaotic evil wizard with fireballs.
Gandalf - also known as Olorin - is a very powerful Maia but he is also incarnated into a "human" form. So he's both not able to use his full potential no longer being a spiritual being and he's not allowed to. The violation of the rules is what divides the good Maia from the bad ones. Sauron and Saruman were/are Maia too. Sauron was originally known as Gorthaur and Saruman as Curumo. Notice also that neither Sauron, nor Saruman, nor Gandalf nor even Morgoth himself don't shoot Fireballs. The worst damage is done when the spirits take massive forms and demolish the world early on. Other than that it seems they have to play by the rules of Ea. This is why Tolkien's magic seems to be all about powerful items which have influence over others rather than magical weapons able to destroy dragons with one blow. Apparently that's impossible in Ea but turning a whole army into a bunch of cowards - or alternatively into selfless heroes - is another thing entirely.
Probably the best example of "magic" in Tolkien's writing would be Meliana's Mantle which was a spell preventing evil spirits from accessing an area. It was so strong that even Sauron couldn't break it. How it worked nobody really knows but my guess is that it too affected the mind rather than the body.
The scene in Hobbit III where Galadriel goes all green is also ridiculous (and completely in line with Jackson abortion of an imagination). She tore down the walls of Dol Guldur because they were magically reinforced just the same way Barad Dur in LotRIII collapses after the One Ring melts down - because that's where the spell was.
TL;DR - There is no magic in Tolkien's world but a closer relationship with the nature of the world which was designed by Ainur/Maiar (angels) and given life by Eru (god). Then Ainur and Maiar (some of them) entered the world and had to play by the rules set by Eru. Magic in middle earth is therefore more like the reddit hierarchy ordinary user, a mod and an admin. Men are the users, Elves are mods Ainur and Maiar are admins and Eru is the owner.
No matter how skilled superusers can only use the features of reddit more efficiently. No matter how much they want mods can't re-write the code of the site. And Admins have to write new scripts and do it bit by bit so as not to put out all the serves. Only the owner can shut down all the serves.