CHICAGO — The Chicago Cubs won the NL Central, becoming the first major league team this season to clinch a division title when St. Louis lost 6-2 at San Francisco.

The Cubs lost 5-4 to the Milwaukee Brewers earlier Thursday night, but captured their first NL Central crown since 2008 when the Giants finished off their victory over the Cardinals.

Wrigley Field was empty when Matt Adams made the final out on the West Coast, yet a loud cheer went up in the neighborhood around the iconic ballpark and several people honked their car horns.

Chicago (93-53) wasted its opportunity to clinch on its own when pinch-hitter Scooter Gennett delivered a tiebreaking, two-run double in the seventh inning for Milwaukee. Keon Broxton homered and Orlando Arcia drove in two runs for the Brewers.

Jorge Soler hit a two-run homer for the Cubs. Justin Grimm (1-1) took the loss.

Jimmy Nelson (8-14) won for the second time in his last 11 starts. Tyler Thornburg got four outs for his 10th save.

GIANTS 6, CARDINALS 2

SAN FRANCISCO — Fist-pumping Johnny Cueto pitched a five-hitter and retired his final 17 batters as San Francisco gained ground in the playoff race with a victory over St. Louis.

Hunter Pence hit a two-run homer, Cueto (16-5) had a go-ahead sacrifice fly and Angel Pagan followed with an RBI single. Denard Span added a two-run single.

The Giants gained a game on the NL West-leading Los Angeles Dodgers, who are ahead by four after losing at Arizona.

San Francisco also moved a game in front of the idle New York Mets and two up on the Cardinals in the chase for the two NL wild cards.

Cueto struck out seven and walked one in his fifth complete game, tying Chris Sale of the White Sox for most in the majors.

Cueto threw 105 pitches and beat Adam Wainwright (11-9) a day after the Giants were swept by San Diego in a lackluster three-game series.

RED SOX 7, YANKEES 5

BOSTON — Hanley Ramirez hit a three-run homer with two outs in the ninth inning to finish off a five-run rally as Boston came back to beat New York and open a two-game lead in the AL East.

New York took a four-run lead after three innings and still led 5-1 before David Ortiz hit a solo shot in the eighth. It was the 537th home run of his career, passing Yankees Hall of Famer Mickey Mantle for 17th on baseball’s all-time list.

Ortiz also had an RBI single off Dellin Betances (3-6) in the ninth.

There were still two on and two outs when Ramirez worked a 3-1 count and sent the next pitch to straightaway center field. The victory in the opener of a four-game series against its archrival snapped Boston’s two-game skid.

Starlin Castro had four hits and new addition Billy Butler drove in two runs in his debut for the Yankees, who have lost four of five.

Joe Kelly (3-0) pitched into and out of a bases-loaded, one-out jam in the top of the ninth.

RAYS 7, ORIOLES 6

BALTIMORE — Evan Longoria homered and drove in five runs, and last-place Tampa Bay again played spoiler in a victory over Baltimore.

The loss dropped the Orioles two games behind AL East-leading Boston and into a tie with Toronto atop the wild-card race.

Tampa Bay has won three straight, including the last two of a three-game series in Toronto. The Rays also defeated the wild card-contending Yankees on Sunday.

Longoria hit his career high-tying 33rd homer off Yovani Gallardo (5-8) with two on in the first inning and added a two-run single in the fourth to increase his team-high RBI total to 91.

Alex Colome worked the ninth for his 33rd save. After the Orioles put runners at first and third with one out, he fanned major league home run leader Mark Trumbo and slugger Chris Davis.

Baltimore went 3 for 15 with runners in scoring position.

Brad Boxberger (4-1) got two outs for the win.

BLUE JAYS 7, ANGELS 2

ANAHEIM, Calif. — Josh Donaldson went 3 for 3 with two doubles and scored two runs in his return to the lineup, Russell Martin hit a three-run homer and Toronto beat Los Angeles.

The Blue Jays remained two games behind first-place Boston in the AL East. They are tied with Baltimore atop the wild-card standings.

J.A. Happ (19-4) took a shutout into the seventh inning and earned his 13th win in his last 17 starts.

Donaldson, last year’s AL MVP, missed a three-game series against the Rays this week with a sore right hip.

In his fourth big league appearance, Daniel Wright (0-3) gave up two runs before exiting in the sixth.

Andrelton Simmons hit a two-run homer to chase Happ.

DIAMONDBACKS 7, DODGERS 3

PHOENIX — Mitch Haniger hit a three-run homer in a five-run sixth inning, and Arizona beat the NL West-leading Los Angeles Dodgers.

Archie Bradley (7-9) struck out seven in six-plus innings and got plenty of run support as the Diamondbacks won their fourth straight and handed starter Rich Hill (3-1) his first loss with the Dodgers.

Los Angeles’ division lead was trimmed to four games when second-place San Francisco beat St. Louis.

Hill and Bradley shouted at each other after Hill bunted an inside pitch in the fifth. Both dugouts and bullpens emptied, but that was the extent of it.

Hill, who was 9-3 with Oakland before being traded to Los Angeles on Aug. 1, allowed a run for the first time with the Dodgers when Kyle Jensen homered in the second. That ended Hill’s streak of 20 consecutive scoreless innings with Los Angeles.

In his previous outing, Hill had a perfect game for seven innings against Miami last Saturday before being lifted because of concerns about a recurring blister.

Brandon Drury set a Diamondbacks rookie record with an RBI in his seventh straight game.

Patrick Corbin got his first save by pitching three scoreless innings.

ATHLETICS 14, ROYALS 5

KANSAS CITY, Mo. — Stephen Vogt homered and drove in five runs, Ryon Healy hit a mammoth three-run shot and Oakland routed Kansas City.

The Athletics put a huge dent in the Royals’ diminishing playoff chances, sweeping a four-game road series at Kansas City for the first time. The A’s outscored the Royals 43-12, the largest Oakland run differential in a four-game series in franchise history.

Healy, who had three hits, sent his titanic drive an estimated 480 feet and it landed above the left-field fountains. He went 9 for 17 (.529) with two doubles, two home runs and seven RBIs in the series.

Joey Wendle had his first career four-hit game and scored three runs as the A’s banged out 16 hits. Marcus Semien added his 25th homer, a three-run shot.

Rookie right-hander Daniel Mengden (2-7) held the Royals to three hits over seven scoreless innings.

Kansas City starter Edinson Volquez (10-11) faced 22 batters and nine scored in 3 1/3 innings.

The Royals have lost eight of their past nine home games.

PIRATES 15, PHILLIES 2

PHILADELPHIA — Andrew McCutchen hit two solo homers, Chad Kuhl pitched six effective innings and Pittsburgh beat Philadelphia.

Jordy Mercer hit a three-run homer, and John Jaso and Sean Rodriguez also went deep to help the Pirates split a four-game series.

Kuhl (4-3) allowed two runs and four hits, striking out five. He retired the first 12 batters before Tommy Joseph lined a double in the fifth.

Jerad Eickhoff (10-14) gave up six runs — three earned — and five hits (four homers) in 6 2/3 innings.

TWINS 5, TIGERS 1

DETROIT — Brian Dozier’s two-run single highlighted a four-run second inning, and Minnesota handed Detroit a crucial loss.

The Tigers split four games with lowly Minnesota, hurting them in the crowded AL wild-card race. Detroit came into the series with a 10-2 record against the Twins.

Hector Santiago (12-8) got the win, holding the Tigers to one run in 5 2/3 innings.

Mike Pelfrey (4-10) lost in his first major league appearance since July 31. He started the game with a 60-pitch limit but lasted only 36, giving up four runs and five hits in 1 2/3 innings.

WHITE SOX 2, INDIANS 1

Jose Abreu extended his hitting tear with a home run and a single, and Carlos Sanchez singled home the winning run in the ninth inning to lift Chicago over Cleveland.

The White Sox took three of four games in the series to conclude a 6-4 homestand against three playoff hopefuls. The first-place Indians remained six games ahead of Detroit in the AL Central.

David Robertson (5-3) pitched a scoreless inning for the win. Chicago starter James Shields gave up one run and three hits in six innings but remained winless in his last nine starts. He was 0-5 with a 10.75 ERA in his previous eight appearances.

Bryan Shaw (2-5) took the loss.