ST. PETERSBURG, Fla. — The Padres could only shake their heads after that one.

It was just so shockingly weird.

“We lost,” Manny Machado said.

They did, 9-4 to the Rays.

But that hardly begins to describe a pitcher’s duel that turned into a carnival on Friday night at Tropicana Field.

“Not our prettiest game on any side of the ball tonight,” Padres manager Craig Stammen said.

The Padres tried to play catch-up for a while and had a decent night against Rays starter Shane McClanahan, who entered the game with a 3.10 ERA and left with a 3.19 ERA after allowing four runs (three earned).

“Not good enough,” Fernando Tatis Jr. said.

The Rays scored three runs in the fourth inning before getting a hit and two more on RBI singles. Their two home runs in the game did not go as far as Xander Bogaerts’ pop fly out to third base was projected to travel.

After Jackson Merrill hit a two-run homer in the sixth inning that got the Padres within two runs,  Bogaerts hit a ball with a projected distance of 386 feet, based on its exit velocity and launch angle. But it was relegated to a pop fly out when it hit the catwalk that rings Tropicana Field’s roof and shot straight down into third baseman Junior Caminero’s glove for the final out in the sixth inning.

“The ball was not bouncing our way tonight,” Stammen said. “That is a fact, and that’s probably the most indicative play of the entire night.”

But that run would have only gotten them to 6-5.

The Rays, whose 80-54 record is best in the American League, did not let any mistake by the Padres go unpunished. They scored five unearned runs in the fourth inning and another run in the sixth thanks in part to what was ruled a single that bounced off Machado’s glove and through his legs.

“They put pressure on you,” Stammen said. “They make you play the defense in different spots to account for their speed and what they do with the bunt game. They get a bunch of people on base, they’re very hard to defend. There’s no doubt about that, and they made it hard to defend after we made a few mistakes.”

Padres starting pitcher Casey Mize (5-8, 3.45) was excellent before losing his grip on the ball and then his grip on the game over the course of a bizarre  series of events in the fourth inning.

“Just self-induced inning there,” Mize said after he hit a batter, made a throwing error and had a run score on a wild pitch. “It’s just what happens when you put yourself in bad positions by not doing little things right, and it led to the big inning that ultimately cost us the game.”

He had thrown 19 pitches and allowed one hit through two innings and got the first two outs of the third on three pitches. A 2-1 sinker to Yandy Díaz was swatted the other way and down the right field line and just over the tall wall there.

That gave the Rays a lead they would never relinquish, though it wasn’t quite as tidy as that.

Mize threw 34 pitches in the fourth, six more than it had taken him to get through the first three innings.

The carnage began when Mize hit Junior Caminero, the first batter, with a 1-2 pitch.

Catcher Freddy Fermin made a long run and a sliding catch in front of the Padres’ dugout on the third base side, and Mize got a comebacker that would have at least eliminated the lead runner and gotten him a second out.

But Chandler Simpson’s grounder got to Mize so quickly that he was ready to throw to second base before Bogaerts got there, and Mize held up his throw and had the ball slip out of his hands and roll into left field. So Simpson was safe and Caminero ran to third.

“It got to me really quick,” Mize said. “And so when I looked, Xander is making his way over there, so I was gearing up to throw, and then my body told me give him a second. And at that point I was already letting go of the ball. I just should have taken a second with the ball in my glove there before I geared up to throw.”

Even with Simpson’s speed, a double play had seemed possible when Mize fielded the ball.

Instead, runners at the corners turned into runners on second and third when Simpson stole second and then turned into bases loaded when Mize walked Jonny DeLuca.

The mayhem had hardly begun.

The Rays’ first run of the inning came when Cedric Mullins dribbled a ball to first baseman Ty France, who made as if to throw home before seeing Caminero was too close to the plate. By that time, Mullins was at first base.

Three pitches later, Mize bounced a 1-2 slurve off the dirt well outside and in front of the plate. The ball caromed off Fermin’s leg and went skyward as Simpson raced home and slid safely in front of Mize’s tag.

DeLuca advanced to third on the play and scored on Mateo’s sacrifice fly.

Taylor Walls followed with the first hit of the inning, which scored Mullins. Walls stole second and scored on a single by Diaz before Jonathan Aranda lined out.

Merrill walked and Bogaerts singled to start the fifth inning, and the Padres loaded the bases when Mateo mishandled Austin Hays’ grounder to second. Fielder’s choice grounders by Fermin and Jake Cronenworth brought in two runs.

The Rays got one of those runs back in the bottom of the fifth after Walls hit a ball at 90 mph off his bat to Machado, who was playing in. The ball rolled into left field after it caromed off Machado’s glove. Walls got to second when David Morgan walked Aranda and scored on Caminero’s single.

The Padres got to 6-4 in the sixth when Ty France walked and Merrill homered.

That was the end of McClanahan’s night and also the last of the Padres’ scoring.

“You have games where things just don’t go your way and you maybe not play good on top of that,” Stammen said. “But the good thing is tomorrow, today doesn’t matter, and we can move on.”