The Pirates had led 1-0 since the first inning but the Cubs pushed across a tying run in the eighth on a Donnie Murphy RBI single.
Marte, however, quickly responded with two outs in the ninth, belting a pitch from Kevin Gregg (2-6) over the left-field wall for a clutch solo homer.
The Bucs had to hang on the bottom of the ninth to secure the victory.
The Cubs decided to send Schierholtz home, but the relay throw from first baseman Justin Morneau nailed him at the plate for the game's final out as Grilli recorded his 32nd save.
Mark Melancon (3-2) credited with the victory as Pittsburgh clinched at least a National League wild-card spot and remained two games behind NL Central-leading St. Louis.
Swim Week Miami Beach 2014 [PHOTOS]