In the fiction of J. R. R. Tolkien, the Wizards of Middle-earth are a group of beings outwardly resembling Men but possessing much greater physical and mental power. They are also called the Istari (Quenya for "Wise Ones") by the Elves. The Sindarin word is Ithryn (sing. Ithron). They were sent by the Valar to help and assist the peoples of Middle-earth to contest Sauron.
The wizards were Maiar, spirits of the same order as the Valar, but lesser in power. The first three were known in the Mannish tongue of Westron as Saruman ("man of skill"), Gandalf ("elf of the staff"), and Radagast ("tender of beasts"). Tolkien never gave Westron names for the other two, one tradition gives their names in Valinor as Alatar and Pallando. Each wizard had robes of a characteristic colour: white for Saruman (the chief and the most powerful of the five), grey for Gandalf, brown for Radagast, and sea-blue for Alatar and Pallando (known consequently as the Blue Wizards). Gandalf and Saruman both play important roles in The Lord of the Rings, while Radagast appears only briefly. Alatar and Pallando do not feature in the story, as they journeyed far into the east after their arrival in Middle-earth.
Tolkien gives multiple names for all of them. In Quenya Saruman was Curumo ("skillful one"), Gandalf was Olórin ("dreaming" or "dreamer"); and Radagast was Aiwendil ("friend of birds"). The Quenya names Morinehtar ("darkness-slayer") and Rómestámo ("east-helper") are given for Alatar and Pallando, though it's not clear which name goes with which wizard.
They came to Middle-earth around the year 1050 of the Third Age, when the forest of 'Greenwood the Great' fell under shadow and became known as Mirkwood. The wizards already appeared old when they entered Middle-earth. They were "clothed" in the bodies of old Men, as the Valar wished them to guide the inhabitants of Middle-earth by persuasion and encouragement, not by force or fear. However, they aged very slowly and were in fact immortal. Physically they were "real" Men, and felt all the urges, pleasures and fears of flesh and blood. Therefore, in spite of their specific and unambiguous goal, the Wizards were capable of human feelings; Gandalf, for example, felt great affection for the Hobbits. They could also feel negative human emotions such as greed, jealousy, and lust for power. It is hinted in the essay in Unfinished Tales that the Blue Wizards may have fallen prey to these temptations, though information published in The Peoples of Middle-earth seems to contradict this version of their history.
Although immortal, their physical bodies could be destroyed by violence - thus Gandalf truly died in the fight with the Balrog, beyond the power of the Valar to resurrect him, Eru Ilúvatar himself intervened to send Gandalf back. Similarly, Saruman was killed when his throat was cut by his own servant in The Return of the King. The Istari also carried staves, which seem to be tied to their ability to wield magic, when Saruman is defeated at Isengard, Gandalf in the same breath casts him from the White Council and breaks his staff (although he retains the persuasive power of his voice).
Though the Valar intervened only rarely in Middle-earth, they sent the wizards as emissaries from Valinor because they had not forsaken the faithful Men and Elves of Middle-earth. In imposing the prohibition against using force to compel the Children of Eru, the Valar sought with the wizards to avoid repeating an ancient error. They had tried direct intervention in the destiny of the Elves in the Years of the Trees by leading the Eldar into the West, but this resulted in many bloody wars and confrontations. In the struggle against the Dark Lord, they hoped instead to help Men achieve their own destiny. Thus Gandalf and the other wizards were meant to use their great wisdom to persuade Men to courses of action which would achieve Men's own goals, rather than trying to dominate them. Saruman failed in this when he tried to set himself up as a commander in opposition to Sauron, but Gandalf remained faithful to his charge.
The wizards landed at the Grey Havens in the North-west of Middle-earth, for the Valar felt that Arnor and Gondor, remnants of Elendil's old kingdom, had the greatest hope of mounting resistance against Sauron. Few of Middle-earth's inhabitants knew who the wizards really were; the wizards did not share their identities and purposes widely. Most thought they were Elves or wise Men; the name Gandalf, meaning "Wand-elf", reflects the belief that he was an Elf.
Saruman originally was the most powerful of the five and was appointed head of the White Council. In T.A. 2759 he took over the defence of Isengard with the consent of the Steward of Gondor, who gave him the key to Orthanc. Saruman was learned in the lore of the Rings of Power, and gradually became corrupted by desire for the Rings and by Sauron's direct influence through the palantír of Orthanc. Eventually he took the title "Saruman of Many Colours" and took robes to match. He assisted Sauron in the War of the Ring, biding time to secure the One Ring for himself, in order to supplant Sauron. But his plans and forces were thwarted by the power of the Ents. Gandalf broke his staff and cast him from the White Council, and Saruman was killed by his servant Gríma Wormtongue in the Shire after the destruction of the One Ring.
During the War of the Ring, it was Gandalf who led the Free Peoples to victory over Sauron. He also became "Gandalf the White", and defeated the traitorous Saruman. After the destruction of Sauron's forces in front of the Black Gate at the mountainous borders of Mordor, Gandalf left Middle-earth and went over the Sea to Aman, along with the Ring-bearers and many of the Elves.
In the course of The Lord of the Rings, it is never made clear what exactly Gandalf and Saruman are. Treebeard tells Merry and Pippin that the wizards appeared after the Great Ships came over the Sea (ca. T.A. 1000, according to Appendix B, some 2,000 years before the time of The Lord of the Rings), but little else is revealed in the narrative. Riding with Gandalf to Minas Tirith at the end of Book III, Pippin wonders what Gandalf really was, and realizes that it was the first time in his life that he had done so. In this passage, Gandalf ponders the ability of the palantíri to see into the past, and recalls events in Valinor from the Years of the Trees - though whether from his own memory is not clear.
The essay given in Unfinished Tales was originally begun in order to be included in the appendices of The Lord of the Rings, but was not completed in time. A more explanatory passage on the nature of the wizards is found at the end of The Silmarillion.