Both teams combined for eight pitchers and 12 runs in a seventh inning that took at least 72 minutes, but after the dust settled the Dodgers had a 9-7 win over the Diamondbacks in one of the wildest games of the season at Dodger Stadium.
Yasmani Grandal delivered the go-ahead single, driving home Corey Seager from third base with a two-out single off Randall Delgado, breaking the tie.
The win for the Dodgers was coupled with the Giants' 4-1 loss to the triple-play-turning Nationals to lower the Dodgers' deficit to just a single game in the National League West. Los Angeles has shaved 5½ games off the lead in 15 days since the All-Star break.
Grandal's single put the cap on a five-run inning for the Dodgers that saw Joc Pederson and Chase Utley each hit two-run home runs to tie the game, followed by a double by Seager, all with nobody out.
For Pederson, who also had a two-run double earlier, he matched a career high with four RBI.
The bottom of the seventh was a rather abrupt turnaround from the top of the inning, one that began with a 3-0 Dodgers lead.
Kenta Maeda was cruising, retiring seven straight batters heading into the seventh, with no runs yet charged to his ledger.
A single by Paul Goldschmidt off the glove of Seager at shortstop and a one-out double by Welington Castillo changed that, pulling the Diamondbacks to within 3-1 and ended Maeda's night after five strikeouts, no walks and 93 pitches.
It was the second straight start with no walks for Madea, who has walked one batter in 23⅓ innings in his last four starts, with 26 strikeouts.
Adam Liberatore walked the only batter he faced in relief in the seventh inning, in his first appearance since Sunday after dealing with right knee soreness.
Joe Blanton allowed a shallow fly ball that somehow dropped for a single in left field, then a more traditional bloop single to right field to allow a run to score, cutting the Dodgers' lead to 3-2. A walk to Rickie Weeks tied the score.
Luis Avilan was brought in to face Michael Bourn with two outs and the bases still loaded, and he induced a short grounder in between the pitchers mound and first base. Avilan made a diving stop, but nobody was at first base for Bourn to beat to the bag. The infield single gave Arizona the lead, and ended the night for Avilan.
Pedro Baez, the fifth pitcher of the inning, got ahead of Goldschmidt 0-2, but then delivered an absolute pipe shot down the middle that Goldschmidt deposited down the left field line for a bases-clearing double to break the game open.
Baez got the win.
Seager added an insurance run in the eighth inning with an RBI double, his second on the night and team-leading 29th of the season.
Kenley Jansen was asked to record the final four outs, and after getting the first out on just one pitch to end the eighth inning, he pitched a perfect ninth to record his 31st save.
Scott Kazmir takes the ball on Saturday night for the Dodgers, a 6:10 p.m. PT start followed by Ferris Bueller's Day Off shown at Dodger Stadium. The Diamondbacks will send Braden Shipley to the mound, making his second major league start.
Home runs: Joc Pederson (14), Chase Utley (7)
WP - Pedro Baez (3-2): ⅓ IP, 1 hit
LP - Zac Curtis (0-1): 0 IP, 2 hits, 2 runs
Sv - Kenley Jansen (31): 1⅓ IP, 1 strikeout