Originally called Olórin, he was accounted as the wisest of the Maiar (with the possible exception of Melian). He was created by Ilúvatar before the Music of the Ainur[1], and was at the beginning of Time amongst the Ainur who entered into Eä.[2] In his "youth", he became one of the Maiar who served Manwë, Varda, Irmo and Nienna named. He was associated with light and fire, much like his peer Varda.[3] Yet his ways often took him to Nienna, from whom he learned pity and patience. He loved the Elves, but he walked unseen among them, or wore a fana that appeared like an Elf, and sent them fair visions in their hearts that made them wiser. Throughout his existence, he followed the example of Nienna, he took pity on the sorrows of the Children of Ilúvatar and drove those who listened to him out of despair.[3]
When the Valar decided to send the order of the Istari (also known as Wizards) to Middle-earth, to counsel and assist all those who opposed the Dark Lord Sauron, Manwë and Varda decided to include Olórin among the five who were sent. At first, Olórin was nervous and described himself as too weak and too afraid of Sauron. Manwë understood, and told him that was one main reason why he should go - to overcome that fear. Furthermore, the One Ring, which held much of Sauron's power, presumably still existed somewhere. Thus, Manwë insisted that Olórin should go as the third, but Varda convinced him to have Olórin go as the second instead.[4] He agreed, and prepared for his departure from the Undying Lands with the other four, arriving about the same time the Necromancer appeared in Mirkwood.
Olórin, like the other Wizards, took the shape of an old man. He was robed in grey and went about as a wanderer and counsellor. At Mithlond he was welcomed by Glorfindel, his friend from Valinor (who had been sent earlier on a similar mission), and Círdan the shipwright, who possessed Narya, one of the Three Elven Rings of Power. Círdan divined in Olórin a sense of strength and power despite his appearance as a bent and aged old man. Círdan gave Narya to Olórin with a prediction of his future struggles with evil, and a promise that it would support and aid him in his labours.[5]
He then began his sojourn in Middle-earth and during many years, he walked among the elves as a stranger, learning from them and teaching them. Unlike Saruman, Olórin did not take up a single permanent residence and never went to the east[6], apparently restricting his activities to the Westlands of Middle-earth, where the remnants of the Dúnedain and the Eldar remained to oppose Sauron. He was known by many names during the long years he wandered: Elves named him Mithrandir, the "Grey Pilgrim", while the men of Arnor named him Gandalf, which became his most common name. He was also known as Incánus (in the south), and Tharkûn to the Dwarves.[4] He later revealed himself as one of the Istari, and eventually became known as not only the wisest but also the most powerful individual in that order.
A legend says that Gandalf was given by Yavanna the Elfstone of Eärendil, to bring to the peoples of Middle-earth as a token that the Valar had not forsaken them. He gave it to Galadriel, bearer of one of the Three Elven Rings and mighty among the Eldar, remarked prophetically that she would in turn pass it to an individual who would also be called Elessar.[7]
Around year 1100, the Istari and Eldar discovered that some evil entity resided in at Dol Guldur in Mirkwood; while some thought a Nazgûl had returned to torment the world, or some new evil was arising, Gandalf began to suspect that perhaps Sauron himself might have returned.[5][8] As in the next two hundred years, evil continued to grow and spread, as well as the source directing it. Gandalf went to Dol Guldur in 2063 to discover its secret.[5] However, the Necromancer fled upon Gandalf's arrival, preventing Gandalf from identifying him.[8] After Gandalf's incursion, the evil there seemed to desist, and its absence allowed for some centuries of calmness.[8]
That peaceful period was known as the Watchful Peace and lasted for almost four hundred years, but the Nazgûl had used this period to prepare for Sauron's return, in 2460.[5] Realising the returning evil, Galadriel formed and reunited the White Council three years later composed of four members: herself, Gandalf, Saruman, and Elrond the Half-elven (who was the bearer of another of the Three Rings). Galadriel wished Gandalf to be the chief of the Council, but he refused the position, wishing to set down no roots and to maintain his independence; Saruman took this place instead because of his vast knowledge and for his pride in not declining from the position.[8] However, he later grew jealous and afraid of Gandalf,[5] which was the reason of his future betrayal.
During his wanderings in Eriador, Gandalf met and befriended the isolated and secretive people of the Hobbits in their country, The Shire. During the Long Winter of 2758 Gandalf came to their aid.[5] It was then when he witnessed and admired the pity and courage that the humble Hobbits reserved in their hearts.[9] He then passed onward but nevertheless would return to visit the Shire occasionally and participate in the Midsummer-eve parties of the Old Took, where he impressed young Hobbits with his fireworks, and his stories about Dragons, Goblins and princesses.[9] He was thus known to be "responsible for so many quiet lads and lasses going off into the Blue for mad adventures". He also met a relatively adventurous Hobbit named Bilbo Baggins, although he was in fact far from "adventuresome."[10]
When King Thráin II, a dwarf of the royal line of Lonely Mountain, disappeared on journey to Erebor, Gandalf looked for him. At some point after 2845 he entered the abandoned city of Khazad-dûm during this search. After this proved to be in vain, the Wizard exited through the Doors of Durin; however this experience did not help him know how to open the doors from the outside.[11] In 2850, his quest led him once more to Dol Guldur, this time in secrecy.[5] He found Thráin in the dungeons, who gave the Wizard his last possessions, the map and key to Erebor.[12] Most importantly, he found out that the Necromancer was not a Nazgûl – it was Sauron himself, and he had taken the last of the Seven Rings from the Dwarf King; Sauron was gathering the remaining Rings of Power and possibly searching for his lost One Ring.
Gandalf escaped Dol Guldur and returned to the White Council.[8] After relating his discoveries, he urged the council to attack Sauron while the One Ring was still lost and while Sauron's power was not yet beginning to be restored . But Saruman said that it was better to watch and wait; that the One Ring had long ago rolled from Anduin to the Sea. The majority of the council agreed with Saruman. Elrond later privately told Gandalf he had a foreboding that the Ring would be found, and that the war to end the Age was coming. Indeed, Elrond added, he feared that it would end in darkness and despair. Gandalf encouraged him, saying there were many "strange chances," and that, "help oft shall come from the hands of the weak". Gandalf did not yet realise that Saruman now wanted the Ring for himself and was secretly searching for it along the banks of river Anduin.
As time went on, the wizard became increasingly troubled by his knowledge of Sauron's resurgent strength. He knew that Sauron was already plotting war from Dol Guldur, and that as soon as he felt strong enough, he would attack Rivendell. Unfortunately, the only power left besides Rivendell to resist an attempt from Mirkwood to regain the lands of Angmar was the dwarves of the Iron Hills.
Over the years, Gandalf became concerned about the weak state of the North. Smaug the Dragon had destroyed both the Kingdom under the Mountain and the town of Dale, and the wizard feared that Sauron might use the desolation around Erebor to regain the northern passes in the mountains and the old lands of Angmar. Gandalf knew that exiled Dwarf King of Durin's Folk, Thorin Oakenshield, planned to battle against Smaug, but he knew that it would not be enough. In 2941,[5] while staying the night in Bree, Gandalf happened across the Dwarf King.[9] Thorin initiated conversation; he had been having a strange feeling urging him to seek Gandalf. The same was intrigued, for he had thought to seek Thorin as well. They found they were taking the same road for a while (Thorin passing through the Shire on his way to the Ered Luin), and they agreed to travel together. Thorin wanted advice, and Gandalf in turn wanted to discuss the Dragon Smaug with Thorin.
Ultimately, Gandalf concocted a plan wherein Thorin could destroy Smaug and recover his family fortune, albeit with a "burglar" of Gandalf's own choosing.
Feeling that a Hobbit should be involved, Gandalf remembered Bilbo Baggins. At first he found only Holman Cotton as Bilbo had left on the occasion of the Elven new year, something that persuaded Gandalf that Bilbo was the right person for the job.[9] He visited Bilbo later, bringing along the kinsmen of Thorin.[10] In the end, Gandalf convinced the reluctant Baggins to become a burglar for Thorin. Gandalf then accompanied Thorin and Company to Rivendell. During the journey Gandalf was instrumental in saving the travellers' lives from several calamities. He saved them from a trio of Stone-trolls, and later obtained the legendary sword Glamdring from their Troll-hoard; Gandalf bore it thenceforth.[13]
He also helped Thorin and Company through the Misty Mountains; when unknowingly they camped in the Front Porch of the Goblin-town, the same captured the whole company except Gandalf, who surprised them much later, killing the Great Goblin and then leading the Dwarves to the exit.[14] It was during this time that Bilbo obtained a "magic ring".[15] Bilbo initially claimed he "won" it from the creature "Gollum" while the company was under the Misty Mountains.[16] The ring conferred invisibility on Bilbo when he wore it, and he kept it secret from Gandalf for some time.
On their escape out, the Company was saved by the Eagles of the Misty Mountains; Gandalf once had healed the Great Eagle from a poisoned wound, and thenceforth they became friends. The Eagles picked them up to their eyrie, and the next day they dropped them to the other side of the Mountains.[16]
Gandalf then sought the hospitality of Beorn, persuading him to welcome and host the whole Company in his hall. But then he left the quest prior to its completion; after leading the Company to the outskirts of the Forest Gate, he gave them some final advice (but little did he know that the lands had changed by then) before they'd enter Mirkwood, and went to attend other obligations.[17][18] The White Council had met under the gravest of circumstances: Sauron's vast power was returning, even without his Ring. Gandalf at last convinced the Council to attack Dol Guldur, to which even Saruman agreed (as by now he feared Sauron as a rival, and wished to delay his search for the Ring). Gandalf joined his peers in assailing Dol Guldur, ridding Mirkwood of the Necromancer's presence, who fled to Mordor to his long-prepared stronghold of Barad-dûr.[19] When he was about to finish his task, news about what happened to Thorin's Company in Mirkwood reached him, and realised that the instructions he gave did not help them; they had lost their way, and then vanished due to the encounter with the Wood-elves, who had captured them. He was anxious to get back to them as soon as possible.[20]
Meanwhile Thorin's quest was successful: Erebor was retaken and Smaug was killed,[21] but when Gandalf finally arrived to the area, he found the Dwarves of Erebor and the Iron Hills preparing for an attack by the Lake-men and the Elves of Mirkwood. He was with Bard and Thranduil and thus revealed his presence, trying to reason with Thorin. When the attack was beginning, Gandalf halted them, to warn that the Orcs and Wargs were coming to claim the treasure. He invited Dáin Ironfoot for council, and soon Dwarves, Elves and Men formed an alliance, and defeated the Orcs of the Misty Mountains in the Battle of Five Armies.[22]
King Thorin was mortally wounded and after his funeral and the reestablishment of Erebor under Dáin, Bilbo and Gandalf followed their way back; they celebrated Yule at Beorn's, and then returned to Rivendell, where he discussed with Elrond the events of Dol Guldur and the Lonely Mountain. Gandalf had accomplished his immediate goal, which was to destroy Smaug, since he could have been used to disastrous effect by Sauron. A large number of Orcs and Wargs also were killed in the North, removing threats to Rivendell and Lothlórien.[9] The two still both agreed that it would be better if the Necromancer were banished from the world altogether.[23]
As Gandalf and Bilbo passed by the site of their former encounter with the stone-trolls, they made sure to recover the gold of the troll-hoard they had buried before the Wizard left to perform other duties and Bilbo returned to the Shire.[23] Gandalf, for his part, found himself amazed by the Hobbit; until then, the Wise had paid no attention to Hobbits and knew little of them. For the rest of his sojourn in Middle-earth, Gandalf took a special interest in Hobbits, and particularly in the Baggins family.
Despite the Council's hopes, Sauron was not weakened by this attack. He had foreseen the move that drove him from Mirkwood, and his retreat was but a feint. Ten years after the attack, Sauron declared himself openly in Mordor in 2951 and rebuilt the Tower of Barad-dûr. The White Council met for one last time in 2953 to debate about the Rings of Power. Saruman quieted his peers claiming to have the knowledge that the One Ring was lost in the Belegaer. After their meeting, Saruman, jealous and afraid of Gandalf, set spies to watch all his movements; this would affect the peaceful Hobbits, as Saruman thus discovered the existence and noted Gandalf's interest in the Shire, and started sending agents in Bree and the Southfarthing.[5]
In 2956, Gandalf met Aragorn, the hidden Heir of Isildur, and soon became friends with him. From that point on Aragorn and Gandalf often worked together towards a common end - the defeat of Sauron.
During this period Gandalf visited the Shire frequently, especially his friend Bilbo Baggins, and his younger nephew, Frodo. He noted Bilbo's unusual youthfulness, despite his advancing age; the suspicious "magic ring" that Bilbo had acquired during his adventure began to weigh on his mind. Gandalf recalled the deceit Bilbo used in originally claiming it for his own -- Bilbo had later admitted to stealing it from Gollum. Gandalf could see that Bilbo was now very preoccupied with the ring and had begun to suspect that the same was indeed a ring of power. Such un-hobbitlike behaviour aroused his suspicions.
In 3001, Bilbo planned what would become known as his Farewell Birthday Party, and at the culmination of the hobbit's speech, Bilbo put on the mysterious ring and disappeared, as a joke on his neighbours. Later as he was bidding farewell to Gandalf, who had known about his plans to leave, Bilbo began to change his mind about leaving his ring to Frodo, as he had earlier agreed. When Gandalf tried to persuade him to leave it, Bilbo became hostile and accused Gandalf of trying to steal the ring for his own benefit, which he referred to as his "precious." Horrified by Bilbo's outburst, Gandalf stood to his full height and projected his power, frightening the hobbit. This brought Bilbo back to his senses; he apologised, admitted that the Ring had been troubling him lately, and left it behind. Bilbo and Gandalf bid each other goodbye before Bilbo left the Shire for his journey.[24] Before leaving the Shire, he convinced Bilbo to leave the Ring for Frodo. He then emphatically warned Frodo not to use it; Gandalf .[25]
Keen now to find out more about Gollum, he sought Aragorn's help to capture him. Studying the records in Minas Tirith, he found the Scroll of Isildur and pieced together the missing history of the One Ring; on his way back to the Shire he got word from the Galadhrim that Aragorn had finally captured Gollum and he went to Mirkwood to meet him. For days he interrogated him in order to verify what he already knew, in 3017. A great fear came over him when he learned that Gollum had been to the Tower of Barad-dûr. Sauron had tortured Gollum and learned not only of the "magic ring", but also the names "Shire" and "Baggins". Gandalf left Mirkwood soon after, and left Gollum with the wood-elves of Northern Mirkwood.[5] He now returned in haste to the Shire, certain that Frodo's ring was not simply a ring of power: it was the One Ruling Ring of Sauron.
Upon returning to the Shire, Gandalf immediately went to Frodo and confirmed his suspicions by throwing the Ring into Frodo's hearth fire, which revealed, in Black Speech, the inscription upon the ring. Gandalf then told a dumbfounded Frodo about the One Ring and its history, and how Sauron would seek to regain it. Instructing Frodo to go to Rivendell with the ring, Gandalf told him to make arrangements to leave the Shire quietly.
While in the Shire, he had a sense of foreboding; in the aftermath of Sauron's attack on Osgiliath, Gandalf heard disturbing news about war in Gondor and a Black Shadow. He started wandering around Eriador, hearing news from the refugees who had a fear they could not speak about, until he met Radagast the Brown who brought a message of Saruman that he must seek him at once; and a warning that the Ringwraiths are looking for the Shire.[26] He went to the Prancing Pony at Bree. Believing that he would not be able to return to Frodo in time, he wrote a letter, urging him to move as soon as possible for Rivendell, and seek someone "Strider" whose real name is Aragorn, with a riddle to identify him; Gandalf would then try to catch up with them when available. He also instructed Barliman Butterbur to send the letter to Hobbiton and to expect a Mr. Baggins that will come under the name of "Mr. Underhill". He left the inn, but Barliman would forget to send the letter.[27]
Soon thereafter Gandalf arrived at Isengard. At their meeting, Saruman at last revealed his desire for the One Ring. He offered to his "old friend and helper" that they take the Ring for themselves and seize power from Sauron. Gandalf rejected this with horror, and was imprisoned by Saruman on the pinnacle of Orthanc. Gwaihir, chief of the Eagles, soon arrived and helped Gandalf escape. Gwaihir's real purpose for visiting Orthanc was to report a sighting of the Nazgûl, as Radagast had appealed to him to do so earlier on. Gandalf knew he must return quickly to the Shire, as Frodo (and the ring) were in grave danger from both Sauron's Nazgûl and now Saruman's treacherous desire for the ring.
Gandalf hurriedly went to Rohan, desiring to find a strong steed; there he obtained Shadowfax from King Théoden, who later resented the gift. This lord of horses and Gandalf forged a special bond, and Gandalf made quick use of Shadowfax's incredible strength and endurance.
Gandalf sped to the Shire. Fortunately, Frodo had already left the Shire without waiting for Gandalf, and was seeking the refuge of Rivendell. Upon arrival Gandalf learned that the Nazgûl, arrayed as Black Riders, had been searching the area. Dismayed, he set out for Bree; Barliman apologised to Gandalf for forgetting to send the letter, worried that the hobbits had left with Strider, the suspicious Ranger. But for Gandalf this was a hope which far exceeded his expectations. After congratulating a puzzled Barliman, and blessing his beer, Gandalf then made for Weathertop, a high point in the region, to observe the surrounding area.
There he was assaulted at night by the Nazgûl, but drove them off after a great battle of light and flame. These phenomena were seen by Aragorn and the hobbits from afar, without knowing it was Gandalf. Before leaving, he marked some stones with the certh G for them to find.
Several days later, Frodo, Aragorn, and company stayed at Weathertop and were confronted by the remaining five Nazgûl. Despite their escape, Frodo was stabbed in the process by the Ringwraith leader with a Morgul-knife.[28] Gandalf was able to evade the four Nazgûl and successfully reach Rivendell and welcomed by Glorfindel. However, several days later, an injured Frodo arrived at the Ford of Bruinen, though the Nazgûl pursued him all the way there. Gandalf, along with Elrond, saved Frodo from the Nazgûl by enchanting the water and sweeping them away.[29]
Elrond called a council after Frodo was healed to consider the momentous decision regarding the ring. There Gandalf explained to the others how Saruman had imprisoned him and how the White Wizard was creating his own army of orcs to rival Sauron's.[26] By chance, representatives of most of the free peoples happened to be in Rivendell already for various reasons. Elrond and Gandalf advised that the Ring should be destroyed in the fires of Orodruin, where it was made. Others dissented or objected, but eventually submitted to Gandalf's plan. Ultimately, Elrond appointed the Fellowship of the Ring as nine walkers, numerically set against Sauron's nine Nazgûl. The relatively small number reflected the realisation by Elrond and the other council members that the quest of Mount Doom would not rely upon strength of arms, but on stealth and good fortune. Gandalf was chosen to lead the company, which included Aragorn, Boromir, Legolas the Elf, Gimli the Dwarf, and the hobbits Frodo, Samwise Gamgee, Peregrin Took, and Meriadoc Brandybuck.
Several obstacles stood in the company's way. The vast Misty Mountains had to be crossed, for Gandalf was determined not to lead the company near Isengard. Gandalf decided to take a southern route to the Redhorn Pass and there to cross the Misty Mountains near Caradhras, thereby traversing the mountain range and avoiding Isengard. When this attempt failed due to a terrible storm he then decided to take the Fellowship through the ruins of Moria, where the remains of the great Dwarf city of Khazad-dûm was now a labyrinth of tunnels under the mountains. Others in the company were loathe enter the maze, as it was now the lair of orcs and something known only as "Durin's Bane".
Fall in Mines of Moria
At the Doors of Durin on the west side of the mountains, Gandalf, after some delay, spoke the password and led the company into the dark. Having been in Moria on an earlier perilous errand, he was somewhat familiar with the underground passages. Eventually the party came to the Chamber of Mazarbul, where Gandalf read the Book of Records, which revealed the fate of Balin, the leader of an ill-fated attempt to re-colonise Moria. Soon after, the party was attacked by orcs, and forced to flee the chamber. By then Gandalf was well aware of their location, and he led the party quickly towards the eastern exit.
Unfortunately Durin's Bane caught up to the group at the Bridge of Khazad-dûm. Gandalf and Legolas immediately realised what it was: a Balrog of Morgoth, a servant of the first dark lord. In a spectacular display of bravery Gandalf faced the demon and broke the bridge both stood upon, leaving the beast to fall into a seemingly bottomless chasm. But the Balrog's whip lashed out, and grasped Gandalf by the knees, causing him to fall into the pit. While falling, Gandalf shouted "Fly, you fools" and vanished into the abyss.[30]
Yet Gandalf did not die; he and the Balrog fell for a long time, and wizard was burned by the Balrog's fire. Then they plunged into a deep lake in the depths of the mountain, which Gandalf later said was cold as the tide of death and almost froze his heart. They fought in the water until finally the Balrog fled into dark tunnels, where the world is gnawed by nameless things, older even than Sauron. Gandalf pursued the creature until it led him to the spiraling Endless Stair, and they climbed it until they reached Durin's Tower in the living rock of Zirakzigil, the pinnacle of the Silvertine above the clouds. There they fought, until at last Gandalf threw down his enemy, and the Balrog broke the mountain-side as it fell. Then darkness took Gandalf, and he passed away. His body lay on the peak. The entire battle, from the confrontation on the Bridge of Khazad-dûm to the mutual demise of the Balrog and Gandalf, had taken ten days.
Resurrection
Then darkness took me, and I strayed out of thought and time, and I wandered far on roads that I will not tell... 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.
—The Lord of the Rings, The Two Towers, Book Three, Chapter V: "The White Rider"
But Gandalf's spirit did not depart Middle-earth forever at this time. As the only one of the five Istari to stay true to his errand, Olórin/Gandalf was sent back to mortal lands by Eru, and he became Gandalf once again. Yet, as he was now the sole emissary of the Valar to Middle-earth, he was granted the power to "reveal" more of his inner Maiar strength. This naked power that lay within him was seldom used during the remainder of his time in Middle-earth, as his mission was essentially the same: to support and succour those who opposed Sauron. Nevertheless, when Gandalf's wrath was kindled his "unveiled" strength was such that few of Sauron's servants could withstand him.
Three days later he was found by the windlord Gwaihir, the Lord of the Eagles, who had been sent by Galadriel to find him. Gandalf was carried to Caras Galadhon in Lothlórien, where he was healed, given a new staff, and clothed in white, and thus became Gandalf the White. He soon learned that Frodo and Sam had left the Fellowship and were attempting the quest of Mount Doom alone.
As Frodo was beyond his assistance now, Gandalf promptly went south to Fangorn Forest, where he met the Three Hunters: Aragorn, Legolas, and Gimli, and gave them messages from Galadriel. Then he called forth Shadowfax, and rode with them to Edoras. There he found that Saruman's spy Gríma Wormtongue had deceived King Théoden into hopeless impotence. Gandalf quickly deposed Wormtongue and encouraged Théoden to ride west to war against Saruman. Gandalf by now was keenly aware that the great war to end the age was beginning; if Saruman conquered Rohan then Gondor would be alone with enemies on all sides.[31][32]
At Gandalf's encouragement King Théoden went west to Helm's Deep where he was quickly besieged; Gandalf then searched for Erkenbrand and the forces of the Westfold, which he later found and led to the Deep, thus breaking the siege. Meanwhile, the Ents (along with the Hobbits Merry and Pippin) moved against Saruman and sent Huorns against the orcs, resulting in the utter ruin of the outer walls of Isengard and the complete annihilation of Saruman's orcs. After the battle, Gandalf went to Orthanc with Théoden, Aragorn, and a small group. There Saruman rejected Gandalf's offer of forgiveness with contempt. Gandalf then broke Saruman's staff and cast him from the Order and the Council. Gandalf imposed a strict watch on Isengard by the Ents and then advised King Théoden to ride to Gondor's defence as soon as possible. The wizard's mind had already turned to Gondor and the coming climactic battle in the east.[33]
As a 'reward' for Pippin, who had foolishly gazed into a palantír, Gandalf took the Hobbit with him to Minas Tirith, the last bastion of the west. Soon after arriving, Gandalf confronted Denethor II, the Ruling Steward, and learned that he was near despair over the death of his eldest son, Boromir. Pippin entered the Steward's service in payment of the debt that he and Merry owed, the death of Boromir. Ostensibly they were allies, but the Steward treated him with disrespect and suspicion. When Faramir, the Steward's younger son, returned from Osgiliath and was attacked by Nazgûl, Gandalf upon Shadowfax drove them away by revealing the power within him; later Faramir told him that Frodo and Sam were still alive and headed towards Mordor.
The city was soon besieged by a vast force from Mordor, led by the Witch-king of Angmar. An ill-advised counter attack resulted in Faramir receiving a wound from a poisoned dart; he lay near death inside the Tower. Still, Gandalf encouraged the men of Minas Tirith to have hope, and dispelled the fear of the Ringwraiths by his very presence. But Sauron's catapults hurled flaming bolts upon the city; soon the first circle of the city burned unchecked. Denethor now lost all heart as the city burned and his only remaining son hovered near death; he abandoned his leadership of the city. Gandalf then took it upon himself to direct the defense of the city. When the gigantic ram Grond destroyed the ancient entrance to the city, Gandalf placed himself alone at the ruined gateway. The Witch-king then appeared in the midst of the blasted gate upon a black horse and threatened Gandalf with death; but Gandalf did not move — seated upon Shadowfax he defied the mightiest of Sauron's minions. However, the stand-off ended inconclusively, as the morning arrived along with the host of the Rohirrim. Hearing the horns of the Riders of Rohan, the Witch-king departed.
But Gandalf did not pursue his foe, for Pippin brought him news that Denethor was about to commit suicide in the high tower, burning himself and his son Faramir on a pyre like the heathen Kings of old. Gandalf rushed to stop this madness and was able to save Faramir, but not Denethor, whose despair and grief had overcome his mind. Gandalf also learned how it was that Denethor's will had been broken: Denethor clutched a palantír in his hands as he burned. Clearly Denethor had been using the stone's special properties for some time — extending his vision far beyond those of mannish eyes, but also wrestling in thought with Sauron. And even though Sauron could not completely overwhelm Denethor's mind, his courage was daunted by knowledge of the vast might of Mordor. Thus the shadow entered into the capital of Gondor.
Nevertheless, and against all hope, the siege was broken. Éowyn of Rohan and the hobbit Merry defeated the Witch-king, whose last wail was heard by many as he was reduced to impotence. Soon after, Lord Aragorn arrived with a large valour of men from the southern fiefs upon a captured pirate fleet from Umbar. The forces of the men of the west then utterly defeated Sauron's attack against Minas Tirith, relieving the city and killing virtually all of the invaders. Gandalf's carefully laid plans and words of wisdom, along with acts of heroism not seen since the elder days, had defeated Sauron's first move.
The Fall of Sauron
In Minas Tirith, Gandalf was selected by Aragorn, Imrahil, and Éomer (the remaining lords of the west) to be their leader in the coming final battles. This would be the culmination of Gandalf's efforts in Middle-earth. Fully aware that the west would stand or fall on the outcome of Frodo's mission, he advised the lords to drive north to the Morannon, thereby drawing Sauron's eye away from Frodo's likely location. This plan surely would result in a catastrophic loss for the outnumbered army, but it gave Frodo a chance to achieve the quest of Mount Doom.
Led by Gandalf and Aragorn, the army of the West crossed the Anduin and marched north, pausing occasionally to announce their coming and to dispatch small numbers of men to lesser tasks. Upon arriving at the Black Gate, the forces halted and prepared for battle. As they ordered their companies, the foul Mouth of Sauron rode forth to parley with them; he revealed Frodo's mithril-coat and Arnor-blade and implied that their owner was captured and tortured. The emissary of Sauron then proposed that the forces of the west surrender; Gandalf however was undaunted, and, seizing his friend's belongings, rejected Sauron's offer. In shock, the Mouth of Sauron turned back towards the Black Gate, which slowly opened to reveal a vast army of orcs and trolls advancing on the lords of the west. Sauron's trap was sprung.
Yet Sauron himself became the victim of Gandalf's trap. Unbeknownst to all, Frodo and Sam had succeeded in scaling Mount Doom and even as the Battle of Morannon began Frodo stood at the Crack of Doom. But the power and lure of the ring finally overcame his will and he placed the ring upon his finger, claiming it as his own. Immediately the Nazgûl were summoned by their lord, as he in terror realised his blunder: his enemies intended to destroy his ring.
But Gandalf's foresight proved accurate again as the creature Gollum, who had been doggedly following the Ring-bearer, seized the ring from Frodo, and, while celebrating his reunion with "his precious," unwittingly fell into the fires of Orodruin. The ring was unmade as the fiery mountain erupted. The tower of Barad-dûr and the Towers of the Teeth began to collapse, their foundations crumbling, the Ring-wraiths burned out like shooting stars, and Sauron was reduced to a mere shadow of malice, never to torment the world again. With Sauron gone, his forces scattered like frightened insects; the Men of the West now set upon them with fury. Gandalf announced the success of the Ring-bearer and the end of Sauron; the quest had been fulfilled. Seeing that victory was achieved, Gandalf then mounted on Gwaihir the Eagle for a third time, and set out to see if Frodo and Samwise had survived the tumults of Mount Doom. To his great relief, the two were found on the slopes of Orodruin, clinging to life amid the volcanic eruptions. The great quest was over.
Fourth Age
In Minas Tirith, Gandalf and the remaining members of the Fellowship reunited. At the coronation of King Elessar, Gandalf (at Aragorn’s request) set the crown upon the King’s head, and declared "Now come the days of the King, and may they be blessed while the thrones of the Valar endure!". Thus Gandalf ushered in the new age of men.
After the coronation and wedding of Aragorn to Arwen, Gandalf left with the rest of the remaining Fellowship on the journey home. For Gandalf, it was his last long journey in Middle-earth. His errand to Arda had been fulfilled; Sauron had been defeated. He said farewell to his friends one by one until at last only the four Hobbits remained at his side. At the borders of the Shire he, too, turned away. He left the Hobbits to settle with the Shire, for the shattered pieces of evil still remaining in the world were no longer his concern, and went to talk to "moss gatherer" Tom Bombadil.
What Gandalf did during the next two years is unknown; it is possible that his "long talk" with Bombadil was just that. At any rate, on 29 September 3021, he met Frodo at Mithlond, ready to take the White Ship over the sea to Aman. He wore Narya openly on his finger, and Shadowfax was beside him (perhaps even to take ship with him). His mission was over, and his homecoming after more than 2000 years was nigh. He bade farewell to Samwise, Merry, and Pippin (the latter two of whom he had forewarned of the passage), then boarded the ship beside Frodo, Bilbo, Elrond, and was never seen again in Middle-earth.[34]
The ship passed west upon the sea, and then took the hidden straight path to Valinor: Gandalf became Olórin once more. There, presumably, he dwells still in the gardens of Irmo. Olórin, the wisest of the Maiar and the sole Istar to remain true to his mission, had successfully kindled the hearts of the free people in Middle-earth to overcome the evil of their time. In a large way, it was his victory.