ST. PETERSBURG — Jonny DeLuca hit a game-tying two-run homer off closer Mason Miller in the ninth inning — a ball that fell out of outfielder Samad Taylor’s glove and over the Tropicana Field wall — and Jorge Mateo lined a walk-off single in the 11th to give the Rays a 5-4 extra-innings win over the Padres on Sunday afternoon.

The victory sealed the American League-best Rays’ MLB-leading and franchise record-tying 14th sweep of the season. It came against odds that bordered on absurd: the Padres were 59-0 when leading after eight innings this season, and the Rays were only 2-48 when trailing after eight.

“That’s probably the most exciting one we’ve had this year,” starter Drew Rasmussen said.

With the Rays down two runs and two outs in the ninth, Junior Caminero singled to center to keep the game alive. DeLuca then launched a fly ball to the left-field corner against Miller, who had allowed only two home runs since joining San Diego last August. Taylor tracked the ball to the warning track and appeared to make the catch, but his momentum carried him into the lower portion of the wall — the same cutout that made Evan Longoria’s famous Game 162 homer possible — and the ball fell from his glove and landed on the other side for a game-tying home run.

“I don’t know if it goes down as an error in the books, but in my mind, it’s an error,” Taylor told reporters. “It hit my glove and should be caught.”

DeLuca grinned as he rounded the bases. “You don’t want it to end that way and you always want to be the hero in that situation,” DeLuca said. “Obviously, I love that wall.”

Caminero’s leadoff single that set up the ninth-inning rally came after he had already launched his 37th home run of the season off lefty Robbie Ray in the fourth inning, tying Yordan Alvarez for the AL lead. “I said, ‘Are you kidding me?’” Caminero said of DeLuca’s homer. “I said, ‘Oh, the game’s over right there. The game’s over. We’re winning no matter what.’”

The teams traded zeroes in the 10th before San Diego pushed across a run in the top of the 11th on a wild pitch and a sacrifice fly. In the bottom of the frame, Liam Hicks singled to center, moving pinch-runner Richie Palacios to third. Pinch-running catcher Kenny Piper stole second, and the Padres intentionally walked Chandler Simpson to load the bases for DeLuca. He hit a bouncer to shortstop Xander Bogaerts, who bobbled the ball, allowing Palacios to score. Mateo then ripped a line drive to left field — his first career walk-off hit — to end it.

“It feels great,” Mateo said through interpreter Kevin Vera. “I wish that it was like that every single day.”

Manager Kevin Cash kept it simple: “The guys are pumped right now. Rightfully so.”

Rasmussen, who watched the final innings from the dugout, put the win in a larger context for a Rays club chasing October. “This is a series we can point to and tell our guys who haven’t experienced postseason baseball, ‘Every day is like this,’” Rasmussen said. “It’s a roller-coaster ride. Games are close, and you win on the margins.”

“I don’t think I’ve ever seen it before,” Rasmussen added of DeLuca’s wall-aided homer. “It’s one of those plays we’ll look back on at the end of the year and probably just be grateful for the moment.”