The Pirates won their fourth in a row and seventh in eight games, overcoming a two-run deficit over the final two innings.
Pedro Alvarez hit a two-run homer for Pittsburgh in the eighth to bring about a 4-4 tie and the Pirates then capitalized on two mistakes by the Astros to win it in the ninth.
Starling Marte reached on a single off Edgar Gonzalez (0-1) to open the ninth and was then erased at second when Snider grounded into a fielder's choice.
Martin lifted a 3-2 pitch to shallow right field and both second baseman Jake Elmore and right fielder Jimmy Paredes closed on the fly ball. The fielders ran together and the ball fell in safely, allowing Snider to score the winning run. Paredes was charged with the error.
Justin Wilson (4-0) worked the top of the ninth to get the victory.
Beautician charged with giving client fatal silicone butt injection
Astronomers offer more expansive view of universe