The victory deep into extra innings brings them to within two wins of making their second consecutive World Series appearance.
Cody Bellinger grounded a 3-2 pitch from Junior Guerra into right field, scoring Manny Machado, who slid home and touched the plate with his left hand to beat the tag and end a thriller that took 5 hours, 15 minutes.
The Dodgers struck out 17 times; the Brewers fanned 15 times.
Neither team was able to get much scoring going at Dodger Stadium, taking a 1-1 tie into the ninth and then deep into extra innings.
With the Brewers leading 2-1 in the best-of-seven series, the defending NL champion Dodgers went ahead when Brian Dozier singled home a run in the first inning off Gio Gonzalez.
Milwaukee, seeking its first World Series appearance since 1982, tied the score in the fifth when pinch-hitter Domingo Santana hit an RBI double against Rich Hill.
Both teams wasted plenty of chances. Through nine innings, the Brewers went 0 for 8 with runners in scoring position and the Dodgers 1 for 9.
With one out, Machado had a broken-bat single to left and went to second on Guerra's wild pitch.
Bellinger, who entered as a pinch hitter in the sixth, also had the defensive play of the game. He 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.
Game 5 of the NLCS is Wednesday, 2:05 p.m. at Dodger Stadium. Clayton Kershaw is expected to start Game 5 for the Dodgers against Brewers ace Wade Miley.
The winner of the seven-game NLCS goes to the World Series to face the victor of the Red Sox-Astros matchup in the American League Championship Series.
The Associated Press contributed to this story.
Share pictures or video of your Dodgers spirit using #abc7dodgers, and you may see yourself on ABC7!