Jiraiya could have beat pain.
Jiraiya's one of the most loved Naruto characters. his death against pain was not only tragic but very sad too.
But one important question arises, could have Jiraiya beaten pain?
To know this, I'm going to analyze some of Jiraiya's techniques and put them against Pains. The ultimate factor for Jiraiya's defeat against pain was not power level but his inability to find out pain's secret early along with his own intention to not retreat when given the opportunity.
Jiraiya could have killed the Hell path making it impossible for Pain to revive the paths, then take out the path who absorb Jutsu using a kunai to cut him.
from there, Jiraiya will just have to summon the toad's stomach as he did in cannon to get rid of all the summoned beasts before ending it by killing the summoner with a Rasengan.
use Cho Odama Rasengan to obliterate the Asura path and then off pannel the path who can extract soul with Yumi Numa.
what will b left after that is Deva's path who should be defeated after a very difficult fight by Jiraiya with the 5 seconds weakness in his power to use Shinra Tensei.
the only attack that will give Jiraiya some trouble is Chibaku Tsensei which should be deal with by Jiraiya by either turning the shere into mude to get out or use oil + fire to destroy the core and end the jutsu.
For me its clear Kishi just wanted Jiraiya dead, so that Naruto can grew into a legend cause there is no real reason for Jiraiya to loose, he was well equipped to fight pain. The way he was taken by surprise by asura path because nerf was also forced (Jiraiya should have sensed him in Sage mode). So its what it is. Pain himself confirm that Jiraiya could have indeed won but the plot wanted otherwise.
This is the love between a student and a teacher. Jiraya knew he'd die, even sunade knew he'll be killed soon but still she let him go.