LOS ANGELES (AP) — By the time Manny Machado rounded third base, the Los Angeles Dodgers had already started streaming out of the dugout.

After more than five hours of tension-filled baseball, they were certainly eager to celebrate.

Cody Bellinger singled home the winning run with two outs in the 13th inning Tuesday night to give Los Angeles a 2-1 victory over the Milwaukee Brewers that tied the NL Championship Series at two games apiece.

The slumping Bellinger, who began the night 1 for 21 in these playoffs, was chased all the way into left field by teammates. Even manager Dave Roberts ran out to congratulate his outfielder, who got soaked with a Gatorade shower.

“I think we gave each other a big hug,” Bellinger said. “I think it was the first time I ever got mobbed out in the outfield.”

Bellinger laced a full-count pitch from Junior Guerra into right field to score Machado, who was nearly picked off second base moments earlier. Instead, he slid home and touched the plate with his left hand to beat Christian Yelich’s throw and finally end an October nail-biter that took 5 hours, 15 minutes.

“One of the crazier games, where there’s really no margin on either side,” Roberts said. “The bullpen, what they did tonight against a very good offensive club, my hat’s off to these guys.”

It was the fourth extra-inning postseason game in Dodger Stadium history, and the home team’s first such win since beating Philadelphia in Game 4 of the 1978 NLCS.

“It was a great baseball game, it really was,” Yelich said. “Both sides had opportunities and they were just able to cash one in there at the end.”

After a quick turnaround, Game 5 in the best-of-seven series is Wednesday afternoon, with Wade Miley pitching for the Brewers on three days’ rest against fellow lefty Clayton Kershaw.

The teams return to Milwaukee for Game 6 on Friday.

“We lock it in, win one tomorrow, and we feel a lot better heading home,” Yelich said.

With one out in the 13th, Machado hit a broken-bat single to left field and went to second on Guerra’s wild pitch. With first base open and a struggling Yasmani Grandal on deck followed by the pitcher’s spot, the Brewers chose to pitch to Bellinger — and it cost them.

“Honestly, I didn’t think he was going to throw me a strike,” Bellinger said. “And then once I noticed he was attacking me, I just tried to put the ball in play and hopefully find a hole this time.”

Milwaukee manager Craig Counsell said: “I thought it was worth the risk of trying to expand to Bellinger, and if the at-bat goes to Grandal, we walk Grandal.”

Bellinger, who entered as a pinch hitter in the sixth, also made a diving catch on his belly of a ball hit by Lorenzo Cain leading off the 10th, spreading his arms out and sliding like a snow angel in right field.

“I played right field in the minor leagues a lot before I started playing center field. I haven’t been there much lately,” Bellinger said. “But it’s kind of like riding a bike. I saw it hanging up there, and ran as fast as I could and dove for it.”

Both teams used all their position players and wasted numerous chances. Los Angeles went through its entire bullpen.

The Dodgers struck out 17 times — all against Milwaukee relievers — and have whiffed 49 times in the series. The Brewers fanned 15 times.

“Exhausting,” Los Angeles outfielder Chris Taylor said. “Just a mental and physical grind all the way to the end.”

Dodgers starter Rich Hill allowed one run and three hits in five innings.

The Brewers tied it 1-all in the fifth on pinch-hitter Domingo Santana’s RBI double that took one hop against the right-field wall with Yasiel Puig scrambling in pursuit.

The Dodgers led 1-0 on Brian Dozier’s RBI single in the first off Gio Gonzalez, who left after twisting his ankle while trying to field an infield single by Puig in the second.

Gonzalez has a high ankle sprain and will probably need to be replaced on the roster, Counsell said.

The sellout crowd of 53,764 was considerably noisier than on Monday, when Enrique Hernandez criticized Dodgers fans for being too quiet. Joc Pederson and Bellinger waved blue rally towels in the dugout.

But the Dodgers again struggled at the plate after going 0 for 10 with runners in scoring position during a 4-0 loss in Game 3.

Milwaukee put the potential go-ahead run on third in the seventh before Cain grounded out against Dylan Floro.

The Dodgers had runners at the corners in the eighth against hard-throwing Josh Hader, who pitched for the second consecutive day. Pinch-hitter Matt Kemp struck out to end the threat.

The Brewers had another chance in the ninth against closer Kenley Jansen. With fans on their feet, pinch-hitter Travis Shaw struck out with a runner on third to end the inning.

In the 10th, Ryan Braun singled with two outs and stole second against Jansen, who struck out Jesus Aguilar.

And when Bellinger finally ended it, the only NLCS game that had lasted longer was the New York Mets’ 15-inning victory over Atlanta in Game 5 in 1999, which took 5 hours, 46 minutes.

“Let’s get something to eat,” Dozier said afterward. “I’m starving.”

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