A.J. Burnett allowed only an unearned run on two hits over seven innings to get the win, his third in as many starts.
Burnett (4-2) struck out three and gave way in the eighth for Jason Grilli, who survived a two-out walk to keep the Pirates in front.
Hanrahan came on in the ninth, but after retiring the leadoff man he gave up singles to Chris Heisey and Todd Frazier. Miguel Cairo, however, struck out swinging and so did Ryan Hanigan to end the game and give Hanrahan his 13th save.
Brandon Phillips drove in the only Cincinnati run in the first with a sacrifice fly. Pittsburgh took the lead in the sixth on a two-run, two-out double by Matt Hague.
Johnny Cueto gave up the two runs on just five hits over seven innings to take the loss.