The Pirates captured their fourth in a row and moved within 13 victories of their first winning season in 21 years. Pittsburgh overcame a two-run deficit to hand the Marlins their fourth straight loss.
Miami held a 2-1 lead heading into the Pittsburgh fifth, which Garrett Jones opened with a single. Jones was erased on a fielder's choice grounder from Josh Harrison, who then stole second.
Marlins starter Tom Koehler (3-7) hit Jordy Mercer with a pitch, after which both runners moved up on the first of Koehler's two wild pitches in the inning.
A single by pitcher Charlie Morton drove home Harrison with the tying run and Mercer came in on another wild throw from Koehler.
The Pirates added a run in the eighth on a sacrifice fly from Pedro Alvarez.
Morton (4-3) worked seven innings to get the win, allowing two runs on six hits with five strikeouts. Mark Melancon faced three batters in the ninth to claim his sixth save.
Wisconsin business offering 'therapeutic cuddling' forced to close
Exploding whale video goes viral on Internet