CHICAGO: Jhonny Peralta hit a two-run homer with two outs in the ninth inning to give the St. Louis Cardinals a dramatic and at-times bad-tempered 6-5 win at the Chicago Cubs on Wednesday.

The victory maintained St. Louis’ gap atop the National League Central ahead of hard-charging Pittsburgh, which completed a series sweep of San Diego.

Meanwhile, American League Central leader Kansas City held on for a victory over struggling Tampa Bay, while West division leader Houston lost against Cleveland, and Minnesota swept Baltimore.

The Cubs were poised for victory when they led 5-4 and reliever Pedro Strop quickly retired the first two batters in the ninth.

However, Matt Carpenter followed with a four-pitch walk, and Peralta connected on a drive that barely cleared the wall in left field.

Cardinals closer Trevor Rosenthal gave up a two-out double to Addison Russell in the bottom of the ninth, but struck out Dexter Fowler to end it.

St. Louis manager Mike Matheny and catcher Yadier Molina were ejected in the eighth for arguing a ball call.

Pittsburgh beat the San Diego Padres 5-2 to complete its 10th series sweep of the season to tie a club record.

Gregory Polanco, Andrew McCutchen, and Jung Ho Kang had RBI singles in a three-run eighth, all with two outs.

Kansas City’s Lorenzo Cain and Jarrod Dyson hit two-run homers and Alcides Escobar contributed four hits as the Royals beat Tampa Bay 9-7.

Dyson and the Rays’ Logan Forsythe both had inside-the-park homers; the first time in 18 years there were two in a game.

Tampa Bay, swept in a doubleheader on Tuesday, fell for the 10th time in 11 games.

Cleveland’s David Murphy drove in two runs with a double in the eighth inning to lift the Indians 4-2 over Houston.

Murphy broke a 2-2 tie by pulling a pitch from Joe Thatcher over the head of the right fielder to score rookie Francisco Lindor and Michael Brantley.

Indians starter Trevor Bauer (8-5) allowed a two-run homer in the first but settled down nicely, allowing no more runs and no walks in eight innings.

Minnesota’s Brian Dozier and Joe Mauer hit consecutive home runs with two outs in the sixth inning, propelling the Twins past Baltimore 5-3 to complete a three-game sweep.

Manny Machado and Chris Davis hit consecutive homers in the eighth for the Orioles to narrow the gap, but Twins closer Glen Perkins got his 28th save from as many attempts.

New York pitcher Jacob deGrom allowed just two hits over eight innings to steer the Mets over San Francisco 4-1 and back-to-back road series victories.

DeGrom (9-6) allowed a double in the third inning and a single in the fourth, then retired 13 consecutive batters. The NL rookie of the year, deGrom struck out 10 and walked one.

Their crosstown rivals, the New York Yankees, also won, edging Oakland 5-4.

All-Star slugger Mark Teixeira homered twice while Stephen Drew, who entered as a late-game defensive replacement in a 1-for-24 batting slump, homered in the eighth to give New York a 5-2 lead.

New York closer Andrew Miller, in his first appearance after a month-long injury absence, nearly gave back all of that lead by allowing a two-run shot in the ninth to Marcus Semien and then a runner on second before Ben Zobrist ground out on a tight call at first base to end it.

A.J. Pollock hit a three-run homer during a five-run second inning that helped the Arizona Diamondbacks beat Texas 7-4, Adam Eaton hit a walk-off home run in the 11th inning for the Chicago White Sox to beat Toronto 7-6, and Jefry Marte got an RBI double for his first major league hit, then added a solo home run that sent Detroit past Seattle 5-4.

Los Angeles beat Colorado 3-2 for its fifth straight win, Milwaukee beat Atlanta 6-5, Clayton Kershaw struck out 13 while ending his personal five-start winless streak in the Los Angeles Dodgers’ 5-0 win against Philadelphia, and Boston topped Miami 6-3.