The Pirates need to defeat Cincinnati once in their final two meetings to earn the right to host the Reds in the National League wild card game. Cincinnati would be at home for the wild card contest if it defeats Pittsburgh both Saturday and Sunday.
Marlon Byrd had three hits and drove in the first two Pittsburgh runs with a single in the third.
Cincinnati cut its deficit in half in the fourth on a home run by Todd Frazier, but Alvarez delivered his 35th long ball of the season two innings later.
A.J. Burnett (10-11) picked up the crucial victory with an eight-inning performance, during which he allowed a run on five hits with six strikeouts. Jason Grilli gave up a leadoff single in the ninth, but then benefited from a double play to pick up his 33rd save.
All of the Pittsburgh runs came off Homer Bailey (11-12). He surrendered four hits and four walks in five innings.