and Freddie Freeman drove in the tying and go-ahead runs as the Dodgers reclaimed a lost lead in the seventh inning and hung on for a 6-5 victory.

“It’s tough, it’s tough,” Dodgers manager Dave Roberts said of the challenge of playing the Rays at home. “It was tough in one sense years ago when no one was showing up and it was just kind of a down environment. But now, they pack it out for this ballpark and there’s a lot of energy. You can see those guys feed off of it. It’s no wonder that they play really well at home.”

With Clayton Kershaw holding the Rays scoreless for the first three innings, the Dodgers built a 3-0 lead.

Max Muncy’s average had sunk below .200. He did homer in St. Louis in the first game of this sprawling 10-game road trip, but was 2 for 27 before hitting another solo home run leading off the second inning against Rays starter Tyler Glasnow.

Two innings later, Muncy followed J.D. Martinez’s double with one of his own and eventually scored on a wild pitch to build that 3-0 lead.

Kershaw, the National League’s Pitcher of the Month in April who has had a trying time in May, then began to struggle.

A leadoff walk in the fourth signaled trouble. Two batters later, Christian Bethancourt doubled to left field and Manuel Margot ripped a single through the middle to drive in two runs.

An inning later, Kershaw gave up a one-out single to Wander Franco, then left a first-pitch fastball to Harold Ramirez up in the zone. Ramirez lined it over the wall in right field for a two-run home run that gave the Rays the lead.

Kershaw was 5-1 in April with a 1.89 ERA while holding hitters to a .175 batting average. In five starts in May, he is 1-3 with a 5.55 ERA and hitters are hitting .313 against him.

“This was such a great team win. I didn’t have anything to do with it, unfortunately,” Kershaw said. “Personally, it’s frustrating. I felt like I had some good rhythm, good momentum going for a few innings, then just kind of lost it there. My command just became really inconsistent. It’s frustrating. It’s not really something I’m used to having to struggle with.”

The go-ahead rally started at the bottom of the Dodgers’ order with a single by Miguel Rojas. He moved up on a wild pitch and scored on Betts’ RBI single. Betts stole second and trotted home with the go-ahead run when Freeman lined a double into the left-center field gap.

Freeman was on base four times in the game with two walks and two doubles and extended his hitting streak to 16 games.

For Betts, the clutch single raised his average with runners in scoring position this season to .389 (14 for 36). But that’s not the number catching his eye.

“I just know that thing (the scoreboard) says .250 every time I step up there, so we have to work on fixing that,” Betts said of his overall average.

Miguel Vargas padded the lead with a solo home run in the eighth. Roberts called on reliever Evan Phillips for 1 1/3 innings, then turned to Caleb Ferguson to close it out.

Ferguson gave up a double to the first batter he faced, bringing the tying run to the plate. Yandy Diaz’s potential game-tying two-run home run went foul down the right-field line.

“That was scary,” Roberts said. “He’s a scary hitter, man. I don’t like him coming up to bat. I’m just happy that the game finished.”

There were more frights before it did. Ferguson gave up an RBI single to Franco that put the tying run at third base before getting Ramirez to bounce into a game-ending forceout

“That was a gritty win,” Roberts said. “So much respect for this Tampa team, the way they play. They don’t give you anything. And for us to get a lead, and then lose it, and come back and fight back, scratch and claw, it was just overall a really good win.”