After he graduated from Konoha's Ninja Academy, Jiraiya was teamed with Orochimaru and Tsunade under the leadership of Hiruzen Sarutobi. Hiruzen gave them a bell test for the team's first exercise, during which Jiraiya repeatedly fell for Hiruzen's tricks, and for failing to acquire a bell, he was tied to a stump as punishment. Hiruzen encouraged Jiraiya to be more like Orochimaru, but Jiraiya countered that his Transparent Escape Technique was a fair testament to his skills, as he could spy on bathing women without getting caught: Hiruzen offered to accompany him to see if this was true. Jiraiya had a certain interest in Tsunade from their first meeting, and when her breasts developed, she became a frequent target of his peepings. She nearly killed him when she caught him on one occasion, forcing him to be more discreet about his interests. Jiraiya at some point discovered Mount Myōboku, the residence of the toads; in the anime, he was brought there when he tried to summon a toad without first having a contract with them. Fukasaku trained Jiraiya in their ways, most prominently senjutsu. While he was at Mount Myōboku, the Great Toad Sage made a prediction about Jiraiya: that he would travel the world and during that time meet the Child of the Prophecy, a student who would grow up to either save or destroy the world depending upon how Jiraiya taught them. When he returned to Konoha and began training a team of his own, Jiraiya started to suspect that one student, Minato Namikaze, might be the Child of the Prophecy because of his natural genius. As such, he took Minato as his disciple and taught him many of his skills; Minato would eventually teach Jiraiya the same.
Although their team under Hiruzen's leadership had disbanded, Jiraiya, Orochimaru, and Tsunade continued fighting together during The Second Shinobi World War. During one such fight in Amegakure, they were the only three to survive an encounter with Hanzō, for which accomplishment Hanzō dubbed them Konoha's "Legendary Sannin". After the battle, three war orphans approached them and asked to be taught ninjutsu. Jiraiya, guilty for his involvement in the war, decided to stay in Ame for a time in order to look after them. Shortly after he joined them, he discovered that one of the orphans, Nagato, possessed the Rinnegan, once used by The Sage of the Six Paths to save the world. Jiraiya decided that Nagato was the Child of the Prophecy, and as such agreed to teach the orphans ninjutsu so that he might guide Nagato towards the world's salvation. Nagato was a kind child, torn between his desire to not hurt others and his wish to protect Yahiko and Konan. Jiraiya comforted Nagato that it was enough to want to protect people one holds to be important, as the world is plagued with seemingly endless conflict. Nagato decided that it was possible to end the constant bloodshed and, though he didn't know how, that he would someday find the path to peace. Jiraiya was inspired by Nagato's words and started writing what would become The Tale of the Utterly Gutsy Shinobi. After three years of training the orphans, Jiraiya decided they were ready to forge out on their own and he returned to Konoha; he left them a finished copy of Gutsy Shinobi, dedicated to Nagato. News of the orphans' deeds would reach him from time to time, but eventually he heard that they'd all died.
Gutsy Shinobi did not sell well when it was released. Minato - selected as Konoha's Fourth Hokage after Jiraiya refused the position, enjoyed the book, finding the main character very much like Jiraiya. He decided to name his and Kushina Uzumaki's then-unborn son "Naruto" after the main character, hoping that their Naruto would be just as determined as the character (and thus its author). Jiraiya tried to convince them not to since that would make him Naruto's godfather, but Minato and Kushina insisted this was a good thing. Minato died during the Nine-Tailed Demon Fox's Attack, giving his life to seal the Nine-Tails into the newborn Naruto; as one of his last acts, Minato sent Jiraiya Gerotora, on whose stomach he wrote the key to Naruto's seal. Jiraiya guessed that Minato wanted him to help Naruto gain control of the Nine-Tails' power, though he couldn't guess what that power would be needed for.