Gandalf meets up with Aragorn, Legolas, and Gimli while they are searching the edges of Fangorn Forest for traces of Merry and Pippin.
He explains that he fought the Balrog and came out alive.
After falling into the depths of Moria and then climbing to the peak of the Silvertine, Gandalf has been reborn as Gandalf the White, and he is ready to take up an active role in the War of the Ring once more. Perfect.
Gandalf assures Aragorn, Legolas, and Gimli that Merry and Pippin are taken care of, and then leads the trio to Edoras, in Rohan.
There, Gandalf breaks the spell that Saruman (using Gríma Wormtongue) has put on Théoden, and then encourages Théoden to gather his Riders and go to Helm's Deep to fight back the troops of Isengard.
But Gandalf does not personally go with Théoden to Helm's Deep, promising instead to meet up with Théoden there at dawn of the third day.
Théoden starts to lose faith in Gandalf as the battle roars and ten thousand orcs and Wild Men attack Helm's Deep, but his faith is restored when Gandalf arrives as promised at dawn with two types of reinforcement: the army of Erkenbrand of Westfold and a huge host of killer trees.
After the victory at Helm's Deep, Gandalf brings Théoden, Aragorn, Legolas, and Gimli to Isengard. Théoden worries that Gandalf has lost it: what about Saruman?
But when they all arrive, Théoden sees that the walls of Isengard have been pulled down, and the whole place is flooded. All that is left is the ancient central tower of Orthanc.
Waiting for them are Merry and Pippin, sitting among the ruins.
Gandalf and Aragorn have a quick conference with Treebeard, during which they learn that Saruman is a prisoner of the Ents.
Gandalf addresses Saruman in Orthanc, offering to let Saruman go freely, so long as he promises to surrender his staff and the Keys of Orthanc.
Though Saruman attempts to use his magical voice to persuade Gandalf to treat him as a counselor, Gandalf is too smart for Saruman's tricks. He leaves Saruman in prison, snaps his staff, and casts Saruman out of the White Council.
Wormtongue throws the palantír of Orthanc out of the tower and in the general direction of Gandalf in an attempt to get revenge.
Gandalf takes the palantír and wraps it up carefully.
Pippin, bewitched by the palantír, steals it in the middle of the night and looks at it, seeing directly into the Eye of Sauron.
Now that Sauron has been alerted to a hobbit in the area of Isengard, Gandalf knows they have to ride ASAP to Gondor.
Gandalf takes Pippin with him as he gallops on his trusty steed Shadowfax to Minas Tirith.