Jonathan Loaisiga escaped a no-outs, bases-loaded jam in the final inning after New York capitalized on a wild outing by Boston's bullpen, and the Yankees beat the Red Sox 5-3 on Tuesday in the first game of a doubleheader.

Loaisiga pitched a perfect sixth before Boston loaded the bases with no outs in the seventh on three singles — two of them soft, well-placed grounders. Pinch-hitter Travis Shaw lined out to left in his first at-bat since being claimed off waivers Sunday, but the ball wasn't deep enough for a sacrifice fly.

CLICK HERE FOR MORE SPORTS COVERAGE ON FOXNEWS.COM

Loasiga then struck out Kiké Hernandez and Hunter Renfroe — the latter on a caught foul tip — and let out a vicious yell following his fifth save of the season.

Red Sox relievers Garrett Whitlock (4-2) and Josh Taylor combined to walk the bases loaded with one out in the fifth inning before Luke Voit floated a two-run single to shallow center. Second baseman Hernandez sprinted back for the ball but came up inches short of making a sliding basket catch, allowing New York to go ahead 4-3.

Pinch-hitter Giancarlo Stanton followed with an RBI single as New York sent nine to the plate in the inning. Boston's relievers walked six over two innings, loading the bases three times but limiting the Yankees to three runs.

The Yankees have won four straight and 11 of 14 to pull within a game of Boston for an AL wild card spot. The Red Sox snapped out of a 3-11 slump over the weekend with a three-game sweep of last-place Baltimore, but they're still four games back of AL East-leading Tampa Bay after leading the division for much of the season.

Yankees starter Jordan Montgomery returned from the COVID-19 injured list and pitched for the first time since Aug. 1. He allowed three runs in 4 2/3 innings with five hits, two walks and six strikeouts on 78 pitches.

Albert Abreu (2-0) got the final out of the fifth and the win.

Christian Vazquez led off the fifth with a tiebreaking homer against Montgomery that reached the second deck in left field. It was his fifth homer of the season and first since June 27, a span of 34 games played.

Bronx-born Yankee Andrew Velazquez got his first RBIs in pinstripes with a two-run single off starter Tanner Houck in the second that put New York ahead 2-0. Boston tied it on Xander Bogaerts' two-run single in the third.

CLICK HERE TO GET THE FOX NEWS APP

COMING BACK FROM COVID

The Yankees activated catcher Gary Sánchez and Montgomery from the COVID-19 injured list, one day after doing the same with ace Gerrit Cole. First baseman Anthony Rizzo and reliever Clay Holmes remain out after positive virus tests, although Rizzo could return as soon as Wednesday.

The Red Sox got first base coach Tom Goodwin back after he was a close contact to bench coach Will Venable, who tested positive while the team was in Toronto. Both were forced to quarantine in Canada. Venable hoped to rejoin the team as soon as Tuesday night. Left-handed reliever Josh Taylor was also activated two days after being added to the COVID-19 IL.

TRAINER'S ROOM

Red Sox: INF Christian Arroyo (left hamstring strain) was set to start a rehab assignment with Triple-A Worcester. ... OF Danny Santana (left groin strain) could start a rehab assignment this week. ... RHP Ryan Brasier, who was hit in the head by a line drive while rehabbing from a left calf strain, will throw Wednesday and Thursday for Worcester. ... RHP Matt Andriese was designated for assignment.

Yankees: RHP Luis Severino will be shut down from throwing this week while he awaits a second opinion for his tight right shoulder. Severino had an MRI on Monday, but manager Aaron Boone declined to share details on the diagnosis until the second opinion came back, likely on Wednesday or Thursday. ... INF/OF Miguel Andújar (left wrist strain) was scheduled to start a rehab assignment with Triple-A Scranton/Wilkes-Barre.

UP NEXT

New York left-hander Luis Gil (1-0, 0.00 ERA) was set to make his third big league start in the nightcap against Boston right-hander Nathan Eovaldi (10-7, 3.91).