ST. PETERSBURG, Florida — Right-hander Lucas Giolito wanted to one-up White Sox rotation mate Reynaldo Lopez — all in the spirit of friendly competition, of course.

Maybe Giolito did or maybe he didn’t. Not that it mattered after the Sox beat the Rays 2-1 in 11 innings for their second consecutive victory after a seven-game losing streak out of the All-Star break. All was right in the end.

‘‘It’s all good,’’ Giolito said after allowing one run — on a home run by former Sox teammate Avisail Garcia — striking out nine and walking one in 6 2/3 innings in his most impressive start in more than a month.

Giolito was pumped up Friday after watching Lopez handcuff the Rays for seven innings in a 9-2 victory. He declared his intention to ‘‘go out there and do the same thing as [Lopez], if not better.’’

Again, maybe he did or maybe he didn’t. What does it matter?

Here’s what mattered: Battery mate James McCann hit a two-out homer in the ninth against Emilio Pagan to knot the score at 1-1 and save Giolito from a hard-luck loss. A night after the Sox pounded out a season-high nine extra-base hits, it was a most welcome sight.

‘‘I thank the Lord for that one,’’ said McCann, who entered the game in a 2-for-24 slump since he, like Giolito, made his All-Star debut July 9 in Cleveland.

Clutch work by relievers Aaron Bummer, Evan Marshall and Jace Fry also came right on time. Alex Colome nailed down his 21st save to end a stellar night for the bullpen.

What else really mattered? That huge play by McCann was arguably one-upped by the game-winner for the Sox. Yoan Moncada scored all the way from first base on a soft single to right by Jose Abreu against Chaz Roe in the 11th. Moncada was running on the play, but it took a heck of an athlete to pull off taking all three bases in front of him.

‘‘Moncada is one of the most talented players in the league, in my opinion,’’ Pagan said. ‘‘He scored from first on a ball that bounced five times in the infield. I mean, I don’t know if I’ve ever seen that, not even, like, Little League. So it’s crazy.’’

For the Rays, it was their season-high fifth loss in a row. For Moncada, it was a blast from the past.

‘‘It was very exciting,’’ Moncada said (through a translator) of his mad dash from first to home on a single. ‘‘I used to do it a lot in Cuba. I don’t remember another moment like that here in the U.S.’’

Though he remained stuck on 11 victories, Giolito was pumped up for the second consecutive night.

‘‘That’s the type of players we have, always fighting,’’ he said. ‘‘I love to see it because it shows that we’re fighting to the very end. That’s the type of baseball we played in the first half, and now we’re picking it back up here in the second half after that rough start.’’

On the heels of an awful four-game sweep at the hands of the Royals, the Sox have given themselves something to feel good about before heading home after the series finale Sunday.

‘‘After that K.C. series, we came together and said: ‘Hey, we’re better than what we just did. Let’s get back on track,’ ’’ Giolito said. ‘‘And now we are, so keep going from here.’’

NOTE: The Sox put reliever Kelvin Herrera on the 10-day injured list, retroactive to Thursday, with a strained right oblique and recalled right-hander Jimmy Cordero from Class AAA Charlotte. Cordero, 28, was 3-1 with a 0.51 ERA in 17 2/3 innings with the Knights.