Milwaukee had loaded the bases and with one out and the score tied 3-3 when pinch-hitter Schafer dropped the decisive bunt down the third-base line, bringing Jeff Bianchi in from third base.
Jason Grimm (0-2) was hung with the loss.
The play gave Milwaukee its fifth win in six games. Carlos Gomez went 2-for-3 with a home run and three RBI. Jim Henderson (5-5) pitched the ninth to earn the win.
Welington Gomez homered for Chicago in a three-run seventh inning that gave the Cubs a brief 3-1 lead.