MIAMI (AP) -- Yasiel Puig hit his second homer of the game with two out 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 out 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.

It was his 18th homer this year, and the second blown save by Ramos.

Los Angeles starter Brandon McCarthy allowed four runs in 4 2/3 innings, but four relievers blanked Miami. Josh Fields (5-0) pitched a perfect eighth, and Kenley Jansen followed with a 1-2-3 ninth for his 22nd save.