LOS ANGELES (AP) — Down late in the game, the Los Angeles Dodgers were just setting the stage for more timely hitting and another scintillating comeback.

Consecutive doubles by Yasiel Puig and Adrian Gonzalez in the 12th inning gave them a 5-4 victory over the New York Mets on Wednesday night, the Dodgers' eighth win in a row that is the team's longest winning streak in more than three years.

Leave it to Hall of Fame broadcaster Vin Scully to describe the late-night thriller.

"Another incredible moment in the magic castle," he said.

The Dodgers completed a three-game sweep of the Mets with their sixth walk-off win of the season after trailing 4-0 early.

Los Angeles is 40-8 since June 22, the franchise's best 48-game run in the modern era and the best in the major leagues since the 1942 Cardinals went 41-7 from Aug. 11-Oct. 1, according to information provided by the Dodgers from Elias Sports Bureau.

"They just proved why they're hot right now," Mets starter Dillon Gee said. "They came back from behind every single night. They're grinders."

Puig turned a slow bouncer past the Mets' diving shortstop into a one-out double before Gonzalez's double — his third hit of the game and seventh career walk-off RBI.

Pinch-hitter Andre Ethier tied the game with a two-run homer off LaTroy Hawkins in the ninth. Ethier returned after sitting out a day earlier with tightness in his left calf.

"The guy's been out for basically a day and a half, but to go opposite field here? That ball took off," Mattingly said. "Usually nothing goes out at night, especially opposite field. That's pretty amazing what happened right there."

The Dodgers weren't done yet.

After going hitless in his first five at-bats, Puig legged out a double that glanced off Omar Quintanilla's glove and into center field.

"Every time I leave the plate I'm always thinking for second," Puig said through a translator.

Gonzalez hit the next pitch off Pedro Feliciano (0-1) down the left field line, maintaining the Dodgers' 7½-game lead over the Arizona Diamondbacks in the NL West.

The Dodgers closed to 4-2 in the sixth on a fielder's choice groundout by Mark Ellis and a two-out RBI single by Jerry Hairston Jr.

Puig's defense sparkled on a bang-bang play in the second when Justin Turner singled to right field. Puig raced to pick up the ball and fired to third base to nail Marlon Byrd.

Hawkins got hit in the groin on a comebacker by Jerry Hairston Jr. in the ninth, but he stayed in the game after a brief pause.

"It was a direct hit. No cup," he said. "I've never worn a cup in my life, but I might have to start. I felt like I got kicked by a mule. It hurts."

Byrd hit a three-run homer on a 3-0 pitch from Chris Capuano in the third, extending New York's lead to 4-0. Capuano gave up three consecutive one-out hits, including singles by Daniel Murphy and Josh Satin before Byrd connected.

Andrew Brown's RBI double with two outs in the second scored New York's first run.

Gee allowed two runs and seven hits in six innings, struck out four and walked one.

Capuano gave up four runs and a season-high-tying 10 hits in five innings. The left-hander struck out three and walked two. He allowed double-digit hits in consecutive games for the first time in his career.

NOTES: Mets RHP Jeremy Hefner was placed on the DL because of a torn MCL in his right elbow. He is 0-2 with a 7.58 ERA in his last six starts. Manager Terry Collins said it's a chronic condition that is getting worse. "But we'll get him back this year," Collins said. "I do know there's a lot of guys who pitch with this. He's had this, and he's pitched with it, and he pitched pretty stinking good."... Dodgers SS Hanley Ramirez returned to the starting lineup after being limited to one pinch-hitting appearance since Aug. 4 because of a sore right shoulder. ... Although the Dodgers are starting to tout Puig and RHP Hyun-Jin Ryu as NL rookie of the year candidates, Mattingly said, "It's way too early for us to be talking about it." ... Dodgers co-owner Magic Johnson turned 54.