Bailey (8-10) allowed just three hits and one walk while striking out eight as the Reds earned a split of their four-game series at Miller Park.
Hanigan's two-run single ignited a five-run second inning that put Cincinnati firmly in control and also contributed an RBI hit during a four-run fifth.
Brandon Phillips drove in a pair of runs for the Reds, who hold a 5 1/2-game lead over Arizona for the final National League wild card playoff spot.
Brewers starter Wily Peralta (8-13) was roughed up for seven runs on eight hits over 4 1/3 innings.
Khris Davis went 2-for-3 with a solo homer for Milwaukee.
Pistorius testifies he didn't consciously pull trigger when he shot girlfriend
Pregnant Mila Kunis wins 'Best Villain' at MTV Movie Awards