ST. PETERSBURG, Fla. - Rene Rivera could finally celebrate a big hit after early-season struggles.

He had a run-scoring single in the bottom of the ninth and the Tampa Bay Rays beat the Boston Red Sox 2-1 on Thursday night.

"I think any walkoff 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."

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

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

The Rays have won two in a row after dropping the four first games of a nine-game homestand.

"A big night for Rene," Rays manager Kevin Cash said. "He needed that, we needed that. I'm sure he's feeling pretty good."

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

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

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 tied it at 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.

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

"It's amazing the ground that man can cover," Cash said.

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

"We got shutdown tonight," Boston manager John Farrell said. "Credit their guys. They didn't fall behind in the count. We had a couple of opportunities. I thought Hanley had an opportunity there, and Gomes makes a quality 3-2 pitch with a changeup for strike three."

The announced attendance for the three-game series was just 40,874, including 13,834 Thursday.

TRAINER'S ROOM

Red Sox: RF Shane Victorino (right hamstring) didn't play and may also sit out Friday.

Rays: RF Steven Souza Jr. started after leaving Wednesday's game with right forearm cramps. ... 1B James Loney (oblique) went 1 for 4 in a one-game rehab assignment with Class-A Charlotte. ... LHP Matt Moore (elbow surgery) could throw batting practice early next month.

MOVING DAY

After the game, the Rays optioned Dykstra and OF Mikie Mahtook to Triple-A Durham. Tampa Bay will reinstate Loney and LHP Drew Smyly from the 15-day DL for Friday night's game with Toronto. Smyly, out with left shoulder inflammation, will make his first start of the season against the Blue Jays.

SCORING CHANGE

MLB announced that a fourth-inning error charged to Rays SS Asdrubal Cabrera on April 15 was changed to hit for Toronto's Josh Donaldson.

UP NEXT

Red Sox: RHP Rick Porcello faces Baltimore Friday night after allowing eight runs in five innings to the Orioles Sunday.

Rays: Manager Kevin Cash expects no carryover Friday night against Toronto after an April 16 game when Edwin Encarnacion and Evan Longoria were hit by pitches. "We've got to win ballgames," he said.