Ngoepe led off the inning with a single against Carlos Torres (1-3), advanced to second on a wild pitch and took third on pinch-hitter Jose Osuna's fly ball. Harrison drove a ball over the head of right fielder Domingo Santana for his seventh career walk-off hit.
"I love it," Harrison said. "You want to win any game anytime you have a chance, but when you're a kid you always dream about coming up with the walk-off hit. It's always special to come through for your team like that."
Pirates manager Clint Hurdle has come to expect Harrison to come through with the game on the line.
"He's like a microwave. You put something in it and something good is going to happen," Hurdle said. "He lays it all out there."
Tony Watson (1-0) pitched two scoreless innings for the Pirates.
Cole gave up two hits with eight strikeouts and two walks. He retired his last 10 batters.
Milwaukee's Hernan Perez began the fourth inning with his fourth home run, but the Brewers lost for the third time in four games.
Later in the fourth, Josh Bell led off with a double and scored the tying run on a groundout by Gregory Polanco. Bell and Francisco Cervelli each had two hits for the Pirates. Bell is hitting .351 in his last 10 games.
The Brewers have scored just one run in losing the first two games of the series and were held to three hits Saturday on a chilly, windy night. They had scored 57 runs in their previous nine games.
"It was a well-pitched game on both sides and obviously, we faced their three best guys through 10 innings," Brewers manager Craig Counsell said. "So, they did a nice job. It was a difficult night, obviously, to hit as well. The ball really wasn't going anywhere. There weren't any opportunities we missed out on. We just didn't get many runners."
Brewers: LF Ryan Braun (strained right forearm) was not in the lineup for the fourth straight game but said he is hopeful of returning Tuesday when Milwaukee hosts Boston. Braun rejoined the team Saturday after getting an MRI on Friday in Milwaukee and being examined by team orthopedist William Raasch.
Pirates: RHP Jameson Taillon (groin discomfort) was placed on the 10-day disabled list and RHP Josh Lindblom was called up from Triple-A Indianapolis. Taillon was scheduled to start Monday against the Dodgers at Los Angeles, but rookie RHP Trevor Williams will take his place.
Perez made his fifth start of the season at shortstop as Orlando Arcia got the night off after going 1 for 16 in his previous four games. Perez has also started four games each at third base, center field and right field and two in left field.
Cole has given up seven home runs in seven starts. That equals the number he surrendered all last season in 21 starts.
Conversely, Cole made his sixth straight quality. While his ERA is 2.37 in that stretch, Cole has only one win.
Brewers RHP Zach Davies (2-2, 6.07 ERA) will face RHP Tyler Glasnow (1-1, 6.97) to close the three-game series. Davies has won his last two decisions but has yet to pitch more than 5 1/3 innings in six starts. Glasnow notched his first major league win in his last outing as the rookie allowed three runs in a career-high six innings against Cincinnati in his ninth career start.