ST. PETERSBURG, Fla. — Missed offensive opportunties cost the Boston Red Sox another series win Thursday night.

Rene Rivera had a run-scoring single in the bottom of the ninth inning and the Tampa Bay Rays beat the Red Sox, 2-1.

Boston lost 2 of 3 to the Rays to drop their first series in four tries this season.

“We got shut down tonight,” Manager John Farrell said. “Credit their guys. They didn’t fall behind in the count.”

Boston went 1 for 23, including four failed opportunities Thursday, with runners in scoring position over the three-game set.

Brandon Gomes struck out the only batter he faced, Boston pinch-hitter Hanley Ramirez, after falling behind 3-0 with two on to end the seventh.

“I thought Hanley had an opportunity there, and Gomes makes a quality 3-2 pitch with a change-up for strike three,” Farrell said.

Clay Buchholz allowed one run and two hits over six innings for Boston. He struck out 10 and walked three.

“I felt really good,” Buchholz said. “You’re supposed to win the games you feel really good. That didn’t happen tonight.”

Buchholz didn’t allow a run over 21 innings in his previous three road starts against the Rays, dating to 2012. The streak ended when the Rays made it 1-1 in the second on an RBI single by Logan Forsythe.

Boston opened the scoring earlier in the second on Daniel Nava’s sacrifice fly.

Kevin Kiermaier made a diving catch in center, charging toward the infield after first breaking the wrong way on Mookie Betts’ fly with two on and two outs in the fifth.

“Mookie looks like he’s got a tweener, and Kiermaier makes a heck of a diving catch to preserve a couple of runs,” Farrell said. “We’re not catching any breaks right now offensively.”

Allan Dykstra opened the ninth with a single off Anthony Varvaro (0-1). Pinch-runner Tim Beckham went to second on Kiermaier’s one-out single and scored the winning run on Rivera’s hit down the third-base line.

“I think any walk-off is great,” said Rivera, who is hitting .135 after going 1 for 3. “You win the game. You enjoy it. It’s a great feeling.”

Brad Boxberger (2-1) struck out one during a perfect ninth for the win.

Jake Odorizzi of Tampa Bay gave up one run, three hits, three walks and had three strikeouts in 6 2/3 innings.

NOTES: Red Sox right fielder Shane Victorino (right hamstring) didn’t play and may also sit out Friday. … Rays right fielder Steven Souza Jr. started after leaving Wednesday’s game with right forearm cramps. … Rays first baseman James Loney (oblique) started a short rehab assignment at Class A Charlotte.