MIAMI — Yasiel Puig hit his second homer of the game with two outs in the ninth inning Friday night, and the three-run shot helped the Los Angeles Dodgers beat Miami 6-4 for their seventh consecutive victory.

Corey Seager also homered for the Dodgers (62-29), who were one strike from defeat three times before winning for the 27th time in the past 31 games. They’re 33 games above .500 for the first time this year.

The Marlins led 4-3 when Joc Peterson singled on a 1-2 pitch with two outs in the ninth against A.J. Ramos (2-4). It was the first hit by the Dodgers since the fifth inning.

Peterson moved up on a wild pitch, Yasmani Grandal walked on a 3-2 pitch, and both runners advanced on another wild pitch.

Puig fell behind 1-2 before pulling a 94 mph fastball into the home- run sculpture. He slapped his chest twice with both hands as he looked toward the jubilant Dodgers dugout and began his jog.

NATIONALS 5, REDS 0: Gio Gonzalez pitched four-hit ball into the ninth inning, and Bryce Harper extended his mid-July tear with a pair of homers, leading Washington at Cincinnati.

Gonzalez (8-4) snapped his streak of three straight tough-luck losses. He allowed a double and three infield singles before leaving with one out in the ninth after his 113th pitch. Matt Albers gave up three singles, and Matt Grace escaped the bases-loaded threat for his first save.

PIRATES 5, CARDINALS 2: Josh Bell hit a three-run homer off Seung Hwan Oh with one out in the ninth inning for Pittsburgh at home.

Adam Frazier led off the bottom of the ninth with a double and Oh intentionally walked Andrew McCutchen with one out. Bell, a rookie, stepped in and sent a pitch from Oh (1-5) into the seats in left field for the first game-ending hit of his career. The Pirates have won 6 of 7.

METS 14, ROCKIES 2: Jacob deGrom struck out 11 and won his sixth straight start as New York triumphed at home.

Michael Conforto and T.J. Rivera homered, Yoenis Cespedes got four hits and deGrom contributed two singles for the Mets, who trail Colorado by 91/2 games for the second NL wild card.

BRAVES 4, DIAMONDBACKS 3: Atlanta scored two runs in the eighth inning to win at home.

The Diamondbacks lead the majors with 29 comeback wins and were in position for No. 30 when Chris Owings scored the tiebreaking run on a wild pitch in the eighth.

AMERICAN LEAGUE

BLUE JAYS 7, TIGERS 2: Aaron Sanchez pitched six strong innings for his first win of the season for Toronto at Detroitt.

Steve Pearce and Jose Bautista homered for the Blue Jays, who won the first game of a 10-day, 10-game trip.

MARINERS 4, WHITE SOX 2: Robinson Cano hit a three-run drive on his first swing since connecting for the winning homer in the All-Star Game, helping Seattle win at Chicago.

Jean Segura added two hits and scored twice as Seattle started a six-game trip with its third win in four games. James Paxton (8-3) struck out nine while pitching six effective innings in his third straight victory.

RANGERS 5, ROYALS 3: Adrian Beltre hit a three-run homer, pinch-hitter Mike Napoli had a go-ahead two-run shot and Texas rallied at Kansas City, Missouri.

Martin Perez (5-6) allowed eight hits and a walk over seven innings, but kept all that traffic to three runs. Two of those came in the second, when Alcides Escobar homered to left.