NEW YORK — Brett Gardner made a leaping catch at the top of the left-field wall on Justin Smoak’s bases-loaded drive for the final out, and the New York Yankees held on during a nervy ninth inning to beat the AL East-leading Toronto Blue Jays 7-6 on a misty Tuesday night.

A scrambly September game with October implications seesawed to the last swing, and turned at the end in favor of the Yankees. New York won its third in a row and sent Toronto to its fourth loss in five games.

The Blue Jays had already scored twice in the ninth off Dellin Betances when they loaded the bases with one out. Blake Parker, the eighth New York pitcher, suddenly became an unlikely closer, and he struck out Kevin Pillar.

Smoak was up next, and he hit a drive to deep left. Gardner ran back, jumped and corralled the ball at the top of the padding. He immediately leaped in the air to celebrate as the Yankees rushed out to congratulate him. A few minutes later, a replay of the catch drew another ovation from the fans.

Jason Grilli (5-5) allowed a two-run homer to Chase Headley.

Chasen Shreve (2-1) wound up with the win and Blake Parker got his first save since 2013 with the Cubs.

RED SOX 5, PADRES 1

SAN DIEGO — Jackie Bradley Jr. and Chris Young homered and Clay Buchholz pitched six-plus solid innings, and Boston moved into a tie with Toronto atop the AL East.

Buchholz (6-10) was making his first start since Aug. 23 as his last three appearances came out of the bullpen. Working exclusively from the stretch, Buchholz allowed a run, eight hits and struck out six in facing the Padres for the first time.

Paul Clemens (2-5) was charged with five runs and nine hits over four innings.

ASTROS 4, INDIANS 3

CLEVELAND — Corey Kluber lost for the first time since July 3 after Marwin Gonzalez connected for a three-run homer off Cleveland’s ace in the second inning.

Kluber (15-9) had won his previous seven decisions, a span during which he dominated the way he did while winning the Cy Young Award in 2014. But the right-hander had a bad sequence of six batters against the Astros, who have won the first two of four games between the playoff contenders.

Gonzalez added two doubles for Houston, a major league-best 13-4 since Aug. 19.

Reliever James Hoyt (1-0) struck out two in 1 1/3 innings for his first major league win. The 29-year-old rookie replaced Brad Peacock, who was called up to replace an injured Dallas Keuchel and made his first start since April 14, 2015.

Ken Giles, Houston’s fifth reliever, recorded his ninth save.

RANGERS 10, MARINERS 7

SEATTLE — Elvis Andrus had a homer and three doubles, Jonathan Lucroy hit a two-run homer and Texas Rangers held off slumping Seattle.

Texas, which leads the AL West by 8 ½ games, had a season-high seven doubles among its 15 hits and won for the eighth time in 10 games.

Martin Perez (10-10) allowed four runs — two earned — and seven hits in six innings to win for the third time in his last 13 starts. Sam Dyson pitched the ninth for his 32nd save.

James Paxton (4-6) allowed six runs — four earned — and nine hits, throwing 103 pitches in 4 1/3 innings.

CARDINALS 9, PIRATES 7

PITTSBURGH — Matt Carpenter, Randal Grichuk and Jhonny Peralta all homered off closer Tony Watson with two outs in the ninth inning, helping St. Louis rally past Pittsburgh.

The Cardinals were down to their last strike when Carpenter sent a long drive to right-center to tie it 6-6. Grichuk followed two batters later with a two-run shot off Watson (2-4), and Peralta piled on with a solo homer as St. Louis held on to the second wild card in the NL.

Carpenter’s homer was the 15th by a St. Louis pinch-hitter this season, a major league record. Yadier Molina went 4 for 5, including a first-inning grand slam. Mike Mayers (1-1) tossed a scoreless eighth for the win, and Seung-Hwan Oh worked around a solo homer to Jung Ho Kang in the ninth for his 16th save.

ROYALS 10, TWINS 3

MINNEAPOLIS — Kendrys Morales had two home runs, including a three-run blast in Kansas City’s seven-run ninth inning.

Morales hit a two-run shot in the first to help the Royals overcome the loss of catcher Salvador Perez, who left the game with a right wrist contusion after he was hit by a pitch in the sixth inning.

Brian Dozier hit his 39th home run of the season for the Twins, moving him into a tie with Rogers Hornsby (twice) and Alfonso Soriano for fourth-most home runs by a second baseman in a season. He has homered in five straight games, tying Harmon Killebrew and Marty Cordova for the longest streak in Twins history.

Former Twin Drew Butera’s bases loaded single off Brandon Kintzler (0-2) broke a 3-3 tie and got the Royals rolling in the ninth.

Kelvin Herrera (2-4) pitched one inning for the win.

WHITE SOX 2, TIGERS 0

CHICAGO — Jose Abreu hit his fifth homer in seven games, Miguel Gonzalez came off the disabled list to throw 6 1/3 innings of six-hit ball and Chicago cooled off Detroit.

Abreu connected off Matt Boyd (5-3) in the second for his 23rd homer as Chicago got its third win in nine games.

Gonzalez (3-6) struck out four in his first start since Aug. 11 following a groin injury.

GIANTS 3, ROCKIES 2

DENVER — Kelby Tomlinson hit a one-out, tiebreaking single in the ninth and San Francisco rallied to beat Colorado.

Javier Lopez (1-2) got one out in the eighth to earn the win. Santiago Casilla pitched the ninth for his 31st save. He got Gerardo Parra to hit into a double play to end the game.

Buster Posey began the top of the ninth by hitting a grounder to shortstop Daniel Descalso, who overthrew first baseman Parra and allowed Posey to cruise into second. Hunter Pence followed with an infield single off closer Adam Ottavino (0-2), who was then replaced by lefty Boone Logan.

After Brandon Crawford struck out, Tomlinson lined an 0-2 fastball into left field to bring home Posey with the decisive run.

METS 5, REDS 3

CINCINNATI — Yoenis Cespedes hit the most damaging of New York’s four homers, a two-run shot in the seventh inning, as the Mets rallied for their 13th straight victory over Cincinnati.

The Mets’ winning streak is their longest against Cincinnati. The club record against any opponent is 15 straight wins against Pittsburgh in 1986-87.

Curtis Granderson and Jose Reyes had solo shots off Brandon Finnegan. Cespedes connected off Michael Lorenzen (2-1) for his 28th homer. Alejandro De Aza had a pinch-hit homer in the ninth.

Josh Smoker (2-0) allowed one hit in one inning.

ORIOLES 11, RAYS 2

ST. PETERSBURG, Fla. — Manny Machado capped a six-run fourth inning with a grand slam off Jake Odorizzi, leading Baltimore over Tampa Bay.

Odorizzi (9-6) lost for the first time in 10 starts since the All-Star break, giving up seven runs, six hits and three walks over four innings. Machado’s slam was set up by two walks, a hit batter and J.J. Hardy’s two-run double.

Yovani Gallardo (5-7) pitched five innings for Baltimore, giving up two runs (one earned) and five hits while striking out five.

DODGERS 5, DIAMONDBACKS 2

LOS ANGELES — Ross Stripling and four relievers combined on a four-hitter and the rookie helped himself with a go-ahead single in the second inning, leading Los Angeles to its fourth straight win.

Stripling (4-6) allowed two runs and three hits in five innings. The right-hander struck out five and walked none.

Kenley Jansen pitched a perfect ninth to earn his 42nd save in 48 chances in his 400th career appearance. He is two from tying his career high saves set two years ago.

Shelby Miller (2-11) extended his losing streak to five games after giving up five runs and 11 hits in 4 1/3 innings.

BREWERS 12, CUBS 5

MILWAUKEE — Jonathan Villar homered to start a five-run first inning against Jason Hammel, and Milwaukee cooled off Chicago.

The NL Central-leading Cubs had won seven of eight and were 41 games over .500 after winning Monday’s series opener.

But Milwaukee rallied from a 1-0 deficit as its first seven batters reached against Hammel (14-8). Villar homered on Hammel’s second pitch, Ryan Braun had an RBI single, Domingo Santana singled in two runs and Martin Maldonado added a sacrifice fly.

Wily Peralta (6-9) gave up four runs and six hits in 7 2/3 innings, leaving after Anthony Rizzo’s second home run of the game, a two-run drive.

NATIONALS 9, BRAVES 7

WASHINGTON — Pinch-runner Michael Taylor scored the go-ahead run on catcher Tyler Flowers’ throwing error as part of a three-run eighth inning.

Taylor pinch-ran after reliever Jose Ramirez (2-2) walked Ryan Zimmerman. Taylor stole second and, after Danny Espinosa’s walk, scored when an off-balance Flowers threw pinch-hitter Ben Revere’s bunt attempt well to the left of third baseman Adonis Garcia.

Koda Glover (2-0) retired the only two batters he faced to earn the victory, while Mark Melancon earned his 39th save in 42 opportunities.

PHILLIES 4, MARLINS 3

MIAMI — Adam Morgan snapped his major league-worst streak of nine consecutive losses, Odubel Herrera scored three runs and Philadelphia spoiled Miami slugger Giancarlo Stanton’s return.

Morgan (2-9) allowed five hits and one run in six innings.

Ichiro Suzuki hit the first pinch-hit home run of his career, a two-run shot in the eighth for Miami. Stanton was activated from the disabled list about an hour before the game and delivered a pinch-hit single in the fifth for Miami.

Jose Urena (3-6) gave up four runs and seven hits in five innings for Miami, which is 11-23 since Aug. 1.

ATHLETICS 3, ANGELS 2

OAKLAND, Calif. — Joey Wendle hit a go-ahead single during a three-run eighth inning and Oakland rallied to beat Los Angeles.

Ryon Healy, whose single broke up starter Ricky Nolasco’s bid for a perfect game in the sixth, hit an RBI single before Wendle lined a hit to right to drive in pinch-runner Arismendy Alcantara and Marcus Semien.

John Axford (5-4) pitched two innings to get the win. Ryan Madsen retired three hitters for his 28th save.

Los Angeles wasted a mostly strong outing by Nolasco (5-13).