The unlike other Naruto characters, the Three Legendary Sannin -- Jiraiya, Tsunade and Orochimaru -- actually have real-world origins. The trio has clear inspirations in the Japanese folktale Jiraiya Goketsu Monogatari, which was first recorded in the mid-1800s, but has roots going back much further.
Beginning in 1839, over the course of thirty years it became a popular series of 43 novels completed by four different authors. The story of Jiraiya tells the tale of a young lord from the Ogata clan who gains mastery of toad magic and fights alongside a slug princess to bring down an evil snake spirit that had taken over the land. Sound familiar? There's more.
The Real Story Behind Naruto's Jiraiya
Jiraiya Goketsu Monogatari begins long ago, with an evil giant snake spirit preying on humans and vying to take over Japan. To achieve this, it needs to control the Tsukikage clan, one of three clans presiding over the Echigo province, along with the Ogata and Matsuura clans. One day, Lord Tsukikage is attacked by the snake spirit but is saved by a child named Orochimaru. Grateful, Lord Tsukikage adopts the boy as his son. Unbeknownst to the Lord, Orochimaru was already possessed by the snake spirit, who'd orchestrated the whole farce, to begin with. The snake eventually manipulated the lord into murdering all of his children, leaving Orochimaru as his sole successor.
Through Tsukikage, who was also a feudal regent, Orochimaru eventually gains control of the government. With this power, the snake sought two powerful seals that were each under the protection of the Ogata and Matsuura clans. These seals marked documents that showed the feudal government's support to mobilize the military.
By manipulating the lord into convincing the government that their allies were staging a coup, the snake manages to trick the two clans into giving up their seals before wiping them out and throwing the successors of the clans, Jiraiya and Tsunade, off a cliff.
Thankfully, a hermit named Senso Dojin saves them, raises them and trains the pair to avenge their clans. Jiraiya learns toad shapeshifting magic and Tsunade learns slug magic, but their newfound power only resulted in a three-way deadlock. Similar to in Naruto, snake magic could surpass toad magic, toad magic surpasses slug magic and slug magic could defeat snake magic. Jiraiya and Tsunade would need a special sword called the Nakirimaru, or "wave cutting sword," to defeat Orochimaru.
After finding the sword, Jiraiya and Tsunade corner Orochimaru and exorcise the snake demon from him. Together, they reinstate the Ogata and Matsura clans and pardon Orochimaru for his crimes -- at Jiraya's request. Following this, Jiraiya and Tsunade are married and everyone lives happily ever after.
How Folklore Inspired Naruto's Three Legendary Sannin
Jiraiya, Tsunade and Orochimaru were dubbed the Hidden Leafs' Sannin during the Third Great Ninja War and are renowned for being the greatest ninja of their time. Jiraiya specifically clearly drew significant influence from the old heroic tale. Similar to his namesake, Jiraiya was known as a "toad hermit" with a chip on his shoulder, a dedicated friend to Orochimaru and in love with Tsunade.
Jiraya called himself the Toad Sage of Mount Myoboku and had the ability to summon toads the size of a mountain. Although he was famous for his toad-based techniques, he was also skilled at various other powerful ninjutsu and as well as espionage. He was also a gutsy fighter and a loyal friend, which is also similar to his folkloric counterpart. Even after Orochimaru deserted Konoha, Jiraiya still went after him and kept tabs on him over the years.
That being said, Jiraya's relationship with Tsunade is a little more complicated in Naruto than in the old legend, even if his love for the slug princess was all the same. Unlike in the story where they travel alone together and eventually marry, Jiraiya held an unrequited love for Tsunade throughout his entire life. Because she had been through so much grief and loss, Jiraiya resolved to protect Tsunade from afar and keep his feelings to himself. Although, whether she recognized his feelings and couldn't return them, or couldn't bring herself to admit her own feelings is still be up for debate. Regardless, Jiraya's devotion to Tsunade's happiness in both the folktale and throughout Naruto is clear.
As a writer, Jiraiya traveled far and wide in search of knowledge the next generation could use to help the world. While he didn't get a happy ending like the Jiraiya in the tale, he still lived his life with the same heroism as his namesake and, in the end, still saved the day.