BOSTON (AP) — Xander Bogaerts feels like he’s had his share of baseballs caroming off walls this season.
There was no doubt about his game-winning grand slam Monday night.
Bogaerts’ slam hit off a billboard above the back row of seats on the Green Monster in the eighth inning, lifting Boston to an 8-7 victory over Tampa Bay and moving the Red Sox out of the AL East’s basement and ahead of the Rays.
‘‘I hit so many balls out in the outfield — Seattle, Baltimore — off the wall,’’ he said. ‘‘It’s nice to get one to go over. Hopefully next year’s better.’’
Bogaerts is having a strong year offensively, but his power numbers are down. He raised his average to .323 on Monday with seven homers and 78 RBIs.
‘‘You know that power’s in there,’’ Red Sox interim manager Torey Lovullo said. ‘‘We’re seeing it of late. He’s getting that backswing and the ball’s jumping off his bat. I think the upside is unlimited. He’s not going to be a 30-home run guy year in and year out, but I don’t think it’ll surprise anybody if he hits 25.’’
David Ortiz collected his 99th RBI on a night he was honored at Fenway Park for collecting his 500th career homer. It was his first home game since he joined the 500-home run club, hitting it against the Rays on Sept. 12.
Dustin Pedroia had three hits and Brock Holt drove in a run for Boston, which moved out of last place for the first time since June 8.
Brandon Guyer homered on the game’s second pitch to spark a three-run first for the Rays, who lost for the seventh time in 10 games.
‘‘Frustrating loss. Interesting game to say the least,’’ Rays manager Kevin Cash said. ‘‘A lot of good things. A lot of negative things.
‘‘It speaks volumes about this team to continue to come back, but ultimately (the Red Sox) came back last and won the ballgame.’’
Richie Shaffer had a solo homer, and Evan Longoria and Logan Forsythe added run-scoring hits for the Rays.
Jean Machi (1-0) got one out for the win. Robbie Ross Jr. pitched the ninth for his fifth save.
Bogaerts homered off Brandon Gomes (2-6). Jackie Bradley Jr. was hit by a pitch and Mookie Betts and Pedroia singled before Bogaerts hit his homer over the Green Monster.
‘‘I went back and looked at the home run pitch,’’ Gomes said. ‘‘It was actually a halfway decent pitch. He just put a good swing at it. But I’ve got to make pitches earlier than that and should never have gotten into that situation.’’
Tampa Bay scored three runs in the eighth after Boston had taken a 4-3 lead with three runs in the seventh. Grady Sizemore had a two-run double, and Forsythe followed with a sacrifice fly.
In the seventh, Bogaerts had an RBI double high off the Monster. Ortiz’s run-scoring grounder tied it before Travis Shaw’s sacrifice fly.
The Rays had grabbed a 3-0 lead just nine pitches into the game against Eduardo Rodriguez.
Rays starter Chris Archer gave up one run and three hits in five innings despite control troubles. He walked five and threw two wild pitches.
Guyer’s homer went completely out of Fenway, clearing the Monster seats.
Rays: OF Steven Souza Jr., who missed a little over a month with a broken left hand and came off the DL on Sept. 11, had played 10 straight games and was out of the starting lineup. He came in defensively.
Red Sox: 3B Pablo Sandoval was out sick. Lovullo said he came in with a fever and was sent home. … Lovullo said INF Hanley Ramirez won’t come off the DL until his right shoulder is ‘‘pain free.’’
Ortiz’s next RBI will give him nine seasons of 100 or more with the Red Sox.
Daniel Nava was given a warm welcome in his return to Fenway.
A member of Boston’s World Series title team in 2013, he was honored with a video tribute after the second inning and came out of the dugout for a curtain call.
‘‘That was obviously nice,’’ said Nava, who was designated for assignment by the Red Sox on July 30. ‘‘They do things first class over there and they’ve done it with some other guys who have left and come back.’’
Rays: LHP Matt Moore (1-4) is set to start Tuesday. He gave up Ortiz’s 499th and 500th homers.
Red Sox: LHP Henry Owens (3-2) is slated to start. The 23-year-old rookie is coming off his best start when he held the Orioles scoreless over 7 2-3 innings.