LOS ANGELES (AP) — Max Muncy slugged a three-run, walk-off homer in the ninth inning, rallying the Los Angeles Dodgers past the Arizona Diamondbacks 7-4 on Sunday.

After producing just one run through seven innings, the Dodgers tied the game at 4 with three runs in the eighth, then scored again to complete the comeback a day after their historic 22-1 win over the D-backs.

READ MORE: Kathy Griffin Announces She Has Lung Cancer

“You like to think it carries over, but it doesn’t work that way,” manager Dave Roberts said. “Our guys were still grinding and trying to take good at-bats. Fortunately, we got some momentum in eighth inning.”

The World Series champion Dodgers head into the All-Star break at 56-35. They have the second-best record in the majors, and are two games behind San Francisco in the NL West.

“It was nice to end the first half on a high note,” Muncy said, “and have a little momentum going into the break.”

Albert Pujols led off the Dodgers’ ninth with a pinch-hit single against J.B. Bukauskas (1-2), and pinch-runner Zach Reks took second on Zach McKinstry’s sacrifice bunt.

The D-backs intentionally walked All-Star Mookie Betts only to bring up All-Star Muncy, who hit his 19th home run.

“It was a logical move,” Muncy said. “Thankfully, I made them pay for it.”

The Dodgers equaled a franchise record with eight home runs in their rout on Saturday night, the most runs allowed in a game by Arizona. They took two of three from the last-place

D-backs heading into the break, but went 3-4 this week.

Los Angeles kept up the longball barrage when Betts hit his 13th homer leading off the first.

Kenley Jansen (1-2) pitched the ninth for the win.

READ MORE: Wild Pursuit Comes To An End In Baldwin Park

The Dodgers loaded the bases in the eighth against Noé Ramirez on a walk to pinch-hitter McKinstry and singles by Betts and Muncy. Justin Turner singled to right, and Josh Reddick tried unsuccessfully to backhand the ball on the warning track, allowing McKinstry to score.

“It’s all maddening, it’s all craziness,” Arizona manager Torey Lovullo said of the team’s defensive miscues. “There were certainly some plays that I felt we should be able to make.”

After Cody Bellinger struck out, Will Smith tugged on the red number of his jersey, letting plate umpire Todd Tichenor know he’d been hit. Tichenor agreed, forcing in Betts. Chris Taylor singled to right-center, scoring Muncy to tie the game while Smith was thrown out at third in a base-running blunder.

Arizona got home runs from Stephen Vogt and Daulton Varsho.

The D-backs head into the break with a 26-66 mark. Their first half included a MLB-record 24-game road skid last month.

“Losing stinks and nobody likes it,” Lovullo said. “We’ve got to go out and finish the job.”

Varsho homered for the first time this season — and fourth time in his big-league career — in the seventh, a two-run shot off Scott Alexander that extended Arizona’s lead to 4-1. He drove in Vogt, who singled leading off.

Arizona trailed 1-0 when Josh Rojas hit a ground-rule double to right field off Darien Núñez in the fifth. He scored on Josh VanMeter’s single to left-center, giving Arizona a 2-1 lead, before VanMeter got thrown out at second.

Vogt tied the game 1-all in the fourth with a two-out, solo shot off Tony Gonsolin. He gave up one run and four hits in four innings on 83 pitches after the Dodgers had hoped he’d reach 90. The right-hander struck out six and walked one in his sixth start since making his delayed season debut on June 9 after right shoulder inflammation.

D-backs starter Merrill Kelly was cruising along in the sixth when he gave up a double to Muncy, and then left due to cramping in his right leg in the humid, 88-degree conditions.

The right-hander allowed one run and four hits, struck out three and walked one.

MORE NEWS: Scorching Heat, Strong Winds Brings Elevated Wildfire Risk To LA Region

 (© Copyright 2021 The Associated Press. All Rights Reserved. This material may not be published, broadcast, rewritten or redistributed.)