The Tin Woodman and the Scarecrow are regaling each other with tales at the Woodman's palace in the Winkie Country when a Gillikin boy named Woot wanders in. After he is fed and rested, Woot asks the Woodman how he came made of tin.
He relates how the Wicked Witch of the East enchanted his axe and caused him to chop his body parts off limb by limb, because he was in love with her ward, Nimmie Amee. Each chopped limb was replaced by the tinsmith Ku-Klip with a counterpart made of tin. (Since Oz is a fairyland, no one can die, even when the parts of their body are separated from each other.) Without a heart, the Tin Woodman felt he could no longer love Nimmie Amee and he left her. Dorothy and the Scarecrow found him after he had rusted in the forest (an event related in The Wonderful Wizard of Oz) and went with him to the Emerald City where the Wizard gave him a heart. Woot suggests that the heart may have made him kind, but it did not make him loving, or he would have returned to Nimmie Amee. This shames the Tin Woodman and inspires him to journey to the Munchkin Country and find her.
The Tin Woodman, the Scarecrow, and Woot journey into the Gillikin Country and encounter the inflatable Loons of Loonville, whom they escape by popping several of them. They descend into Yoop Valley, where the giantess Mrs. Yoop dwells, who transforms the travelers into animals for her amusement, just as she has already done to Polychrome, the Rainbow's Daughter. Woot steals a magic apron that opens doors and barriers at the wearer's request, enabling the four to escape. Woot, as a green monkey, narrowly avoids becoming a jaguar's meal by descending further into a den of subterranean dragons. After escaping that ordeal, Woot, the Tin Woodman as a tin owl, the Scarecrow as a straw-stuffed bear, and Polychrome as a canary turn south into the Munchkin Country.
They arrive at the farm of Jinjur, who renews her acquaintance with them and sends to the Emerald City for help. Dorothy and Ozma arrive and Ozma easily restores the Scarecrow and the Tin Woodman to their rightful forms. Polychrome takes several steps to restore to her true form. However, Ozma discovers that the Green Monkey into which Woot is transformed has to be someone's form; it cannot be destroyed. Polychrome suggests as a punishment for wickedness that Mrs. Yoop the giantess be made into the Green Monkey, and Ozma thus succeeds in restoring Woot to his proper form.
The Tin Woodman, the Scarecrow, Woot, and Polychrome resume their quest and come upon the spot where the Tin Woodman had rusted and find another tin man there. After they oil his joints, he identifies himself as Captain Fy-ter, a soldier who courted Nimmie Amee after the Woodman had left her. The Wicked Witch of the East had made Fy-ter's sword do what the Woodman's axe had doneâcut off his limbs, which Ku-Klip replaced with tin limbs. He does not have a heart either, but this does not bother him. However, he can rust, which he does one day during a rainstorm. Both woodmen now seek the heart of Nimmie Amee, agreeing to let her choose between them.
The five come to the dwelling of the tinsmith Ku-Klip where the Tin Woodman talks to himselfâthat is, to the head of the man (Nick Chopper) he once was. The Tin Woodman and the Tin Soldier also find a barrel of assorted body parts that once belonged to each of them, but some, like Captain Fy-ter's head, are conspicuously missing. Ku-Klip reveals that he used Fy-ter's head and many body parts from each of them (which never decayed) to create his assistant Chopfyt. Chopfyt complained about missing an arm until Ku-Klip made him a tin one, and he departed for the east.
The companions leave Ku-Klip and continue east themselves to find Nimmie Amee and find themselves crossing the Invisible Country, where a massive Hip-po-gy-raf helps them across in return for the Scarecrow's straw. Reluctantly, he gives it and consents to being stuffed with available hay, which makes his movements awkward. They rest for the night at the house of Professor and Mrs. Swynne, pigs whose nine children live in the Emerald City under the care of the Wizard.
They leave the Swynnes and arrive at the foot of Mount Munch on the eastern border of the Munchkin Country. At its summit is a cottage where a rabbit tells them Nimmie Amee now lives happily. The Tin Woodman and Tin Soldier knock and are admitted by Nimmie Amee, who is now married to Chopfyt. She refuses to leave her domestic life, even to become Empress of the Winkies (which she would become as the Tin Woodman's wife), saying "All I ask is to be left alone and not be disturbed by visitors." The four return to the Emerald City and relate their adventures. Woot is allowed free rein to roam where he pleases, Captain Fy-ter is dispatched by Ozma to guard duty in the Gillikin Country, and the Tin Woodman and Scarecrow return to his palace in the Winkie Country where the story began.

Question: Who gave the Tin Woodman a new heart?
Answer: The wizard of Emerald City.