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.

“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.

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.

STILL STRUGGLING

Cody Bellinger, the NL MVP in 2019, was hitless in four at-bats, dropping his average to .176. He struck out swinging during the Dodgers' rally in the eighth.

BIG AL

Pujols stroked his 3,283rd hit, tying him with Willie Mays for 11th on the career list. He had two home runs in the Saturday night rout, giving him 675 in his career.

TRAINER'S ROOM

D-backs: LHP Madison Bumgarner (left shoulder inflammation) will be re-evaluated during the break. He allowed seven runs (four earned) and nine hits in 4 1/3 innings in a start in the Arizona Complex League on Saturday. Lovullo said Bumgarner's next start could be with the D-backs.

Dodgers: SS Corey Seager (broken right hand) will report to Camelback Ranch after the break, taking at-bats and playing simulated games. He'll be re-evaluated after next weekend. Roberts is hopeful Seager could rejoin the team for its homestand beginning July 19. ... LHP Clayton Kershaw (left elbow inflammation) is playing catch, but will shut it down over the break. There's no timetable for his return. “We don't want any more soreness,” Roberts said. “When he comes back, it's going to be a sprint.”

UP NEXT

D-backs: Haven't announced their rotation coming out of the break.

Dodgers: LH Julio Urías (11-3) will start Friday at Colorado in the opener of a three-game set.

___

More AP MLB: https://apnews.com/hub/MLB and https://twitter.com/AP_Sports