"A Fabricated Past" (造られた過去, Tsukurareta Kako) is episode 462 of the Naruto: Shippūden anime.
Hagoromo finishes his training at Mount Myōboku. A messenger toad arrives and informs Gamamaru that Kaguya has returned, and that they've been unable to contact Hamura. Hagoromo evacuates the village. Before departing, Gamamaru gifts Hagoromo a tag that can be used to replenish his sage power. Hagoromo confronts Kaguya about her actions. Hamura appears and attacks Hagoromo, under Kaguya's control. Hagoromo fatally injures Hamura, changing his Sharingan into Rinnegan. He then heals Hamura with the sage tag Gamamaru gave him. The God Tree turns into the Ten-Tails to fight for Kaguya. The fight goes on for months, until Kaguya was finally sealed, but not before spawning Black Zetsu. The people bound by the God Tree are freed. Hagoromo splits the Ten-Tails into nine tailed beasts. Having been controlled by Kaguya, Hamura understand the fear she had, and decides to depart to the moon to watch over her. Black Zetsu carries on explaining his role in shaping shinobi history to enable Kaguya's return.