PITTSBURGH (AP) -- Pittsburgh's Pedro Florimon drove in the winning run with two outs in the bottom of the 15th inning to give the Pirates a 9-8 win against Arizona on Tuesday.
Florimon's triple brought home Francisco Cervelli to seal a win that moved the Pirates within five games of National League Central leader St. Louis, which was shut out at home by San Francisco.
There were also victories for both New York teams, which lead the respective East divisions. The Mets ended a run of three successive losses by winning at Baltimore, while the Yankees rallied to beat Minnesota thanks to an Alex Rodriguez grand slam homer.
Pittsburgh's Cervelli singled off Keith Hessler (0-1) for his fourth hit of the game and had to time to dash home on Florimon's high flyball that hit the wall in right field.
It was a reprieve for the Pirates after having blown a late five-run lead, sending the game to extra innings. The Diamondbacks missed a succession of scoring opportunities, leaving 11 men on base.
San Francisco's Ryan Vogelsong pitched six scoreless innings to guide the Giants to a 2-0 win at St. Louis.
Vogelsong (9-8) struck out five and walked just one while throwing 101 pitches.
His fellow pitcher Madison Bumgarner did his best work at the plate, notching his first career pinch hit, which keyed a seventh-inning rally.
The Cardinals suffered only their 19th home loss this season from 64 games.
The Mets won 5-3 at Baltimore, with Jacob deGrom holding the Orioles scoreless into the eighth inning.
DeGrom (12-6) gave up one run and one walk in 7 2/3 innings while striking out six, lowering his season ERA to 1.98; second-best in the National League behind the Dodgers' Zack Greinke.
Curtis Granderson hit a solo homer on the game's second pitch and repeated the feat in the fifth to help New York extend its run of wins against the Orioles to nine.
The Yankees came from three runs down to win 8-4 at home against Minnesota, with Alex Rodriguez hitting a slump-busting grand slam in the seventh inning.
A-Rod extended his major league record for grand slams, hitting the 25th of his career off J.R. Graham (0-1) to put New York up 5-4. That snapped his 0-for-18 slump and earned a curtain call from the crowd.
Houston's Marwin Gonzalez had three hits and his 10th-inning leadoff homer to lift the Astros to a 3-2 victory over Tampa Bay.
The game was tied at 2-2 when Gonzalez connected off All-Star closer Brad Boxberger (4-9), sending a full-count fastball into the right field seats.
Detroit scored three runs in the eighth inning to overrun the Chicago Cubs and win 10-8, with Ian Kinsler having five hits.
Nick Castellanos had a two-run single and J.D. Martinez added a sacrifice fly in the tie-breaking eighth.
Martinez and Anthony Gose also homered for the Tigers in a game that was delayed for 2 hours and 17 minutes after a strong thunderstorm hit with one out in the bottom of the third.
The Cubs had won their previous eight home games.
Kansas City's Jarrod Dyson scored the tie-breaking run on the Cincinnati pitcher's throwing error in the 13th inning, giving the Royals a 3-1 win against the Reds.
Dyson led off the 13th with a single and scored when Ryan Mattheus (1-4) fielded a sacrifice bunt but threw past his first baseman, with the ball running down the right field line.
The Royals had forced extra innings when Ben Zobrist tied the game with a homer leading off the ninth inning.
Oakland also won in extra innings, with Billy Butler driving in the winning run in the 10th inning to give the Athletics a 5-4 win against the Los Angeles Dodgers.
Mark Canha opened the 10th with a double for his fourth hit of the game. Butler then lined the next pitch to right field, and the throw from Scott Van Slyke sailed well wide of home plate, allowing Canha to score easily and end the A's season-worst seven-game losing streak.
The Dodgers lost despite another strong performance by ace Clayton Kershaw, who gave up one run over seven innings with seven strikeouts.
Los Angeles' Kole Calhoun and Albert Pujols homered in the first inning to set up a 5-3 win for the Angels against the Chicago White Sox.
Seattle's Hisashi Iwakuma followed a no-hitter in his previous start by limiting Texas to two runs over seven innings as the Mariners beat Texas 3-2.
Toronto's Josh Donaldson hit two homers and Edwin Encarnacion also went deep as the Blue Jays beat Philadelphia 8-5.
San Diego's Melvin Upton Jr. hit two two-run homers against his former team to power the Padres past Atlanta 9-0.
Boston's Boston's Travis Shaw went 4 for 4 and Mookie Betts drove in three runs with a bases-loaded double as the Red Sox beat Cleveland 9-1.
Washington emphatically ended a six-game skid, beating Colorado 15-6, with Yunel Escobar hitting a homer and driving in four runs.
Miami's Ichiro Suzuki had his first four-hit game in over two years, helping the Marlins beat Milwaukee 9-6.