The Maiar (Quenya, singular Maia) were spirits that descended to Arda to help the Valar shape the World. They were supposed to be numerous, yet not many were named. Their chiefs were Eönwë, banner-bearer and herald of Manwë, and Ilmarë, the handmaid of Varda.
Each of the Maiar was associated with one or more particular Vala, and were of similar stock, though less powerful. For example, Ossë and Uinen, as spirits of the sea, belonged to Ulmo, while Curumo (Cunneir), who came to be known in Middle-earth as Saruman, belonged to Aulë the Smith. Others included Sauron (originally also of Aulë's people), Aiwendil, who was known in Middle-earth as Radagast the Brown and belonged to Yavanna, and Olórin, (known by Elves as Mithrandir and by Men of the West as Gandalf), who belonged to Manwë and Varda. Gandalf's ways took him often to the house of Nienna, and from her he learned pity and patience, which perhaps aided him in his later struggles to unite the Free Peoples of Middle-earth against the power of Sauron.
Alatar and Pallando, known as the Blue Wizards, travelled to the East, and never returned to the West; their fate is unknown, though Tolkien wrote that they had probably also failed in their mission, but established cults in the East. The Balrogs, like Sauron, were Maiar corrupted by Melkor, also known as Morgoth. Their associated Vala is not known. Melian served both Vána and Estë.
The Sun and Moon are also piloted by Maia; Arien, a spirit of fire uncorrupted by Melkor, was chosen for her radiant beauty and fierce devotion to the workings of the Valar, was chosen to guard the Sun, while Tilion, a hunter in the company of Oromë, was chosen to steer the moon.
Maiar, like Valar, do not array themselves in fixed form, but can freely change their form. Olorin, or Gandalf, walked among the several peoples of Middle Earth in uncertain form for many years before being sent on the errand of the Valar as one of the Istari.
Also like Valar however, this power can be lost when that power is spent in hate and mockery. Sauron, following the dark trails blazed by Melkor, took upon the form of - and remained - the Dark Lord in the Second Age.
Yet, Maiar retain their immortality. From all indications, when the physical body of a Maiar is destroyed, their spirit wanders houseless and their power diminished, until they are either able to take physical form once more, or are restored by their corresponding Valar. Examples of this can be seen in the threat of Luthien to Sauron upon his defeat at the Tower of Werewolves, whereby it is said:
"Ere [Sauron's] spirit left its dark house, Luthien came to him and that he should be stripped of his raiment of flesh, and his ghost sent quaking back to Morgoth; and she said 'There everlastingly thy naked self shall endure the torment of his scorn, pierced by his eyes, unless thou yield to me the mastery of they tower.'"
Further example includes the resurrection of Gandalf after he and the Balrog of Moria were both slain, one by the other, on the mountain peak of Zirakzigil:
"Naked I was sent back – for a brief time, until my task is done. And naked I lay upon the mountain-top. … There I lay staring upward, while the stars wheeled over, and each day was as long as a life-age of the earth."
It is not clear how, or what, restored Gandalf, though it can be inferred that Manwë played some role in it. It was Manwë, after all, that sent the Istari on their errand to check the power of Sauron in Middle Earth; therefore, by Gandalf declaring that he was sent back "until [his] task is done", indicates some level of Manwe's involvement.