Xander Bogaerts, right, celebrates his three-run homer with J.D. Martinez in the sixth inning Friday night against the Tampa Bay Rays. Michael Dwyer/Associated Press

BOSTON — Xander Bogaerts hit a three-run homer, and the Boston Red Sox stopped Tampa Bay’s six-game winning streak with a 9-8 victory over the Rays on Friday night.

Kevin Plawecki had three hits and two RBI for the Red Sox, who had dropped four in a row. Michael Wacha (9-1) struck out six in six innings, settling down after a shaky start.

Tampa Bay (69-56) began the day on top of the AL wild-card standings. Yandy Díaz, Jose Siri and Ji-Man Choi homered, but the Rays blew an early 4-1 lead.

Boston (61-65) went ahead to stay with two runs in the fourth and fifth and three more in the sixth.

Francy Cordero connected for his seventh homer in the fourth, and Jarren Duran added a sacrifice fly against Ryan Yarbrough (1-8). Kiké Hernández singled home Bogaerts in the fifth, and Plawecki doubled in Bobby Dalbec to give the Red Sox a 5-4 lead.

Bogaerts – who came in batting .219 in August – then had the big blow in the sixth, making it 8-4 with a drive to left for his 11th homer.

Tampa Bay rallied in the eighth, scoring four times before Boston recorded an out. After Siri’s three-run shot made it 9-8, Red Sox Manager Alex Cora replaced Ryan Brasier with Matt Barnes.

Appearing in his third game in as many days, Barnes retired three straight batters with two strikeouts. Garrett Whitlock pitched a 1-2-3 ninth for his sixth save.

The Rays got off to a fast start when Díaz jumped on the game’s first pitch for his eighth homer. Choi connected for a two-run shot in the second, and Harold Ramirez’s sacrifice fly made it 4-1 in the third.

Boston grabbed a 9-4 lead on Alex Verdugo’s RBI triple in the seventh.

TRAINER’S ROOM

Rays: Shortstop Wander Franco (hamate fracture) continues to work out at Tropicana Field. “Rehabbing and strengthening,” Cash said. “We’ll see where he’s at on Monday.” Franco has been on the IL since July 10. … Second baseman Brandon Lowe left because of a left elbow contusion. He was hit by a pitch in the third inning.

Red Sox: Second baseman Trevor Story (right hand contusion) was scheduled to make a second straight rehab appearance for Double-A Portland, but Friday’s game was rained out. … Right-hander Nate Eovaldi (right shoulder inflammation) threw a 25-pitch bullpen session. Cora mentioned that another bullpen session is possible before mapping out the next course of action. “My preference is for him to go out on a rehab assignment to make sure everything goes well,” Cora said. “He always pushes for the opposite, but we have to be smart with this.”