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 summon the Demonic Statue of the Outer Path to defeat Hanzō's men and Danzō's Root shinobi. with the death of his friend,nagato then set up his mind to continue what yahiko's dream,, that is to become the god in order to achieve the peace in his own way.. that is the story that drives him to pain. the death of his parents due to the war and the death of his dear friend yahiko.