Origin of Pain

is episode 173 of the Naruto: Shippūden anime.

Synopsis
Nagato continues telling his story to Naruto and describes the memory of his second pain. Nagato describes how Jiraiya taught them ninjutsu, and also privately told Nagato that he, with his Rinnegan, was the reincarnation of the Sage of the Six Paths. After Jiraiya leaves, the three orphans grow up and start an organization, led by Yahiko, dedicated to bringing peace to Amegakure. Hanzō, the leader of Amegakure, decides that Yahiko's group is a threat to his rule. Hanzō kidnaps Konan and tells Nagato that he must kill Yahiko if he wants Konan to live. Yahiko immediately drives himself onto Nagato's kunai, killing himself for Konan's sake. Nagato is horrified by Yahiko's death and uses his Rinnegan to defeat Hanzō's men.