ST. PETERSBURG, Fla. (AP) — Boston pitcher Joe Kelly was sailing along with a four-run lead in the sixth inning and a fastball that was “pretty good for me tonight.”

The next thing he knew, Kelly was out of the game and the Tampa Bay Rays came back to beat the Red Sox 7-5 on Wednesday night.

“ The sixth inning has become a challenge for our rotation of late,” said Red Sox manager John Farrell.

After Kelly gave up four straight singles and forced in a run with a walk, Brandon Guyer had a two-run, pinch-hit single off reliever Craig Breslow in Tampa Bay’s four-run sixth to tie it.

“I didn’t get ahead of hitters,” Kelly said. “ In the sixth inning, I tried to get too fine with (the fastball) and fell behind hitters. I had to come back and throw it down the middle and they got some hits on ‘em.”

Breslow barely had time to warm up before giving up Guyer’s game-tying hit.

“Joe was in such control of the game and things happened pretty quickly,” Breslow said. “ Still, I had a chance to limit the damage, and it didn’t happen.”

After a tiebreaking run scored on Desmond Jennings’ double- play grounder in the seventh, Jake Elmore gave the Rays a 7- 5 advantage with his solo home run off Edward Mujica (1-1) on his first atbat with Tampa Bay.

Brad Boxberger ( 1- 1) struck out all three batters he faced in the seventh to help Tampa Bay stop a fourgame skid. Steve Geltz pitched the ninth for his first career save.

Dustin Pedroia and David Ortiz homered for Boston.

Pedroia hit a two- run shot off Nathan Karns during a three-run third as the Red Sox took a 3- 1 lead. Hanley Ramirez scored the other run from first base on Mike Napoli’s single that went off Karns’ glove and ended up in center field.

Ortiz made it 4- 1 on a fifth-inning solo homer. The designated hitter moved past Joe DiMaggio into 46th place on the career RBI list with 1,538, and also broke a tie with Chipper Jones for 32nd place on the homer list with his 469th shot.

Mookie Betts had a runscoring single in the sixth for Boston.

Steven Souza Jr. put the Rays up 1- 0 with a firstinning homer. He departed after striking out to the end the sixth due to a right forearm cramp.

Trainer’s room

Red Sox: RF Shane Victorino left after four innings with right hamstring tightness.

Rays: LHP Drew Smyly (left shoulder) will rejoin the rotation Friday. … RHP Alex Cobb (forearm) could have his first bullpen session Friday. … 1B James Loney (oblique) is nearing a short minor league rehab assignment.

Starting time

Red Sox: Kelly gave up five runs and eight hits in 5- plus innings. He struck out seven and walked one.

Rays: Karns allowed five runs, seven hits, four walks and had three strikeouts over six innings.

More Big Papi

Ortiz has the second-most homers against Tampa Bay with 45. Only Alex Rodriguez, with 49, has more. Ortiz has the most RBIs, 153, against the Rays. … He has 30 homers and 76 RBIs at Tropicana Field, the most for any visiting player.

Up next

Red Sox: Tonight’s starter Clay Buchholz ( 1- 2, 6.06 ERA) has not allowed an earned run over 14 innings in winning both of his starts at Tampa Bay since 2013.

Rays: RHP Jake Odorizzi ( 2- 1, 1.74 ERA) plans to attack the strike zone in tonight’s start against Boston, which entered Wednesday leading the AL with 63 walks. “They work at-bats,” Odorizzi said.