Josh Harrison's pinch-hit, leadoff homer in the bottom of the ninth sent Pittsburgh past Miami, 4-3, in the opener of a three-game series.
Marlins reliever Mike Dunn (2-3) worked out of a bases-loaded, none-out jam in the bottom of the eighth after fanning Pedro Alvarez looking and inducing an inning-ending double-play grounder from Russell Martin.
But Dunn couldn't get past Harrison, who stepped in for Garrett Jones and launched the deciding blast just over the wall in right center to end the contest.
"I knew it had a chance. I thought it wouldn't be caught off the bat," Harrison said. I was watching (Giancarlo) Stanton's reaction. When he pulled up and the ball didn't kick back, I knew it was gone."
Bryan Morris (5-4) tossed a scoreless top of the ninth for the win.
Andrew McCutchen hit a two-run double and Alvarez added a run-scoring triple for the Pirates, winners in 12 of their last 17 games to maintain a solid lead over St. Louis in the NL Central.
"There are a bunch of little things that happen which make you think something's going on," said Pirates manager Clint Hurdle, whose club hit a season-best 24 games above .500 at 68-44.
Logan Morrison and Donovan Solano knocked in a run apiece for the Marlins, who have dropped three in a row and five of their last eight.
Miami starter Henderson Alvarez aided his own cause in the second, lofting a fly to center which plated Solano with the game's first run. The visitors loaded the bases with none out prior to the score.
The Fish tacked on two more in the third on back-to-back RBI singles by Morrison and Solano, but the Pirates sprang to life in the home half, tying the score on a two-run double from McCutchen and a run-scoring triple by Pedro Alvarez.
Miami stranded the bases loaded in the seventh when Jeff Mathis flied out.
"We just couldn't get that hit to give us some breathing room," lamented Marlins manager Mike Redmond. "When you're on the road, momentum can turn in a heartbeat When you get a chance to add runs, you have to take it."
In the home eighth, Chad Qualls walked Starling Marte and then gave up a dribbler by Neil Walker that went dead on the fair side of the first-base line. A passed ball moved both into scoring position, ahead of an intentional walk to McCutchen that loaded the bases.
Dunn was able to skirt disaster, though temporarily.
With his Tuesday performance, Bucs starter Jeff Locke has allowed three earned runs or less in 18 of his last 19 starts and in 19 of his 22 starts overall in 2013 ... Locke served up three runs on nine hits with four strikeouts over 5 2/3 innings ... Alvarez ended up working seven full frames, giving up six hits and three runs while fanning six ... Pittsburgh improved to 7-2 on its current 11-game homestand ... Harrison's homer snapped a string of 12 consecutive games in which Marlins pitchers did not allow a home run, ending the longest such streak in club history. The last Major League pitching staff to go 12-or- more consecutive games without allowing a home run was the Atlanta Braves, who went 12 straight from September 14-27, 1998.