After pinch-runner Clint Barmes replaced Davis, Stewart stroked a single up the middle to score Barmes and Starling Marte followed with a double deep to center, plating Mercer and Stewart for a 4-1 lead.
Mark Melancon worked around a two-out single in the ninth to nail down his fifth save of the season. Tony Watson (4-0) spun a scoreless eighth to pick up the victory.
Pedro Alvarez and Davis collected two hits apiece, while Tabata tallied an RBI to help the Pirates snap a two-game slide.
Jeff Bianchi registered the lone RBI for the Brewers, who had a three-game win streak halted.
Neither starter factored in the decision, despite both hurlers yielding just one run. Milwaukee's Wily Peralta struck out four and scattered five hits over seven frames, while Francisco Liriano fanned seven and allowed just four hits over six innings in the start for Pittsburgh.
The Pirates struck in the fourth, as Andrew McCutchen worked a leadoff walk, moved to third on an Alvarez single through the right side and scored on Tabata's groundout to make it 1-0.
The Brewers broke through in the fifth after Khris Davis clubbed a leadoff double and Jean Segura legged out an infield single to leave runners on the corners for Bianchi, who followed with a sacrifice fly to left, scoring Davis easily to tie the game at 1-1.
Pittsburgh threatened in the eighth after putting runners on the corners with two outs, but Alvarez struck out swinging to leave the potential go-ahead run at third.