ST. PETERSBURG, Fla. — Christian Vazquez hit a tiebreaking home run in the seventh inning, Marcus Walden bailed Boston out of a bases-loaded jam in the ninth and the Red Sox beat the Tampa Bay Rays 5-4 on Tuesday night to move into second place in the AL East for the first time since the second day of the season.

The defending World Series champions have recovered from a 3-8 start and improved to a season-high 10 games over .500 at 56-46, moving one percentage point ahead of the Rays (57-47), who have lost seven of eight.

Chris Sale (5-9) allowed two runs on Travis d’Arnaud’s third-inning homer and limited the Rays to just three other hits while throwing a season-high 116 pitches and striking out 10 over six innings. Sale has dropped his ERA from 4.24 to 4.00 in his last two starts.

With one runner on and two outs in the ninth and Boston ahead 5-2, Brandon Workman allowed two walks and a single as the Rays pulled to 5-3, then Walden relieved and his bases-loaded walk made it a one-run game. But the win for Sale was preserved when Austin Meadows grounded out to end the game.

With the score 2-2, Vazquez hit his second career pinch-homer, a drive into the left-field seats off Colin Poche (2-4). Boston boosted the lead to 5-2 in the eighth when Andrew Benintendi hit an RBI groundout and Jackie Bradley Jr. was hit by a pitch from Adam Kolarek with the bases loaded, forcing in a run.

Boston is a big league-best 32-21 on the road, including 5-0 at Tropicana Field, but 1-5 against Tampa Bay at Fenway Park this season.

Rays starter Yonny Chirinos settled after giving up a pair of two-out runs in the first inning — one on a wild pitch allowing Rafael Devers to score from third base and the other on Benintendi’s RBI single.

NOTES: The Red Sox activated Mitch Moreland from the injured list Tuesday and optioned Marco Hernandez to Triple-A Pawtucket … Red Sox infielder Michael Chavis, out of the lineup for a third straight day after experiencing back spasms, pinch hit in the eighth inning and struck out. He remained in the game at second base. … 1B Steve Pearce, who has not played since May 31 due to a lower back strain, is swinging a bat in Fort Myers, but the World Series MVP is not close to a return, manager Alex Cora said. … Rays Manager Kevin Cash said All-Star INF Brandon Lowe, out since July 3 with a right shin bone bruise, was given injection “to get pain out of there” and will be shut down for several days. Lowe, who was wearing a walking boot in the clubhouse on Tuesday, took on-field batting practice Monday. … INF Yandy Díaz (bruised left foot) was placed on the 10-day injured list, while INF Matt Duffy (strained left hamstring) was reinstated from the 60-day IL. Duffy, who hadn’t played in the big leagues this season, started at third base, batted fifth and went 2-for-3 with a walk.