BOSTON — Max Muncy drew a bases-loaded walk and Alex Verdugo had an RBI single during a three-run 12th inning, and the Dodgers beat the Red Sox 7-4 Sunday night in another late-night showdown of last year’s pennant winners.

After playing 18 innings spanning 7 hours, 20 minutes in Game 3 of last year’s World Series, the teams needed 5:40 to decide this series finale. It was Los Angeles’ third win in 14 tries (including World Series games) at Fenway Park.

Boosted by a large and loud contingent of Dodgers fans that were heard the entire weekend, Los Angeles took the final two of a three-game set against the defending champs and sent Boston to its first interleague series loss in Fenway Park since losing to the Chicago Cubs in 2014.

Boston rallied with back-to-back homers from Xander Bogaerts and J.D. Martinez in the eighth against Pedro Báez but then stranded seven runners over the final four innings.

Los Angeles’ Joc Pederson opened the 12th with a walk against Hector Velázquez (1-4), and Cody Bellinger was awarded first base by the umpires when he collided with the pitcher as he was running down the line after first baseman Brock Holt bobbled his grounder.

A.J. Pollock singled before Muncy drew his go-ahead walk. Verdugo then singled, making it 6-4. A third run came on Russell Martin’s fielder’s choice.

Dylan Floro (4-2) pitched 1 1/3 scoreless innings for the victory. Former Red Sox reliever Joe Kelly struck out the final two batters for his first save.

Pollock hit a short three-run homer down the right field line in the first inning against David Price and added an RBI single.

NL All-Star starter Hyun-Jin Ryu went seven solid innings, allowing two runs on eight hits, striking out six and walking one.

Wearing a small paw print on his cap in honor of his dog Astro, who died during the All-Star break, Price gave up four runs, one earned, in five innings, allowing four hits, striking out seven and walking three on a season-high 113 pitches.

Pollock’s homer sliced into the first row — estimated at 326 feet — just beyond the Pesky Pole. He was smiling rounding second, maybe about the short distance it traveled.

Boston scored twice in the first with three infield singles to short mixed into the five singles. Benintendi beat out a bases-loaded grounder that shortstop Chris Taylor made a diving stop on, and Bogaerts, originally on second, raced home for the second run when Taylor’s throw bounced past first.