Gregg (6-5) walked Mark De Rosa to lead off the ninth and allowed Reed Johnson's one-out single before Ward's game-winning shot.
Reliever Chad Gaudin (4-1) pitched two scoreless innings for the win, and Kerry Wood pitched a scoreless ninth for his 25th save in 30 opportunities.
Florida's Jorge Cantu broke a 1-all tie in the third with a three-run homer. Cantu drove Cubs starter Carlos Zambrano's pitch over the scoreboard in left field for his 21st of the season. Josh Willingham's two-out triple scored Dan Uggla later in the inning for a 5-1 lead.
The Cubs cut the deficit to 5-3 on De Rosa's two-run homer in the fourth, a shot off Marlins starter Josh Johnson over the wall in left field for his 14th home run of the season.
Johnson allowed three runs and five hits in six innings. He walked three and matched a career-high with eight strikeouts, set in three previous appearances.
The Cubs are unbeaten on the road since a 9-2 loss at Arizona July 22, and have won four straight on their current six-game road trip. They pushed their lead in the NL East to five games over Milwaukee, which played the Los Angeles Dodgers later Friday night.
Zambrano fared better than his previous start, when he allowed a sesaon-high nine runs in four innings Aug. 9 against St. Louis. Zambrano pitched six innings this time, allowing five runs and four hits with six strikeouts.
Chicago scored first on Zambrano's two-out RBI single in the second, and the Marlins tied it in the bottom of the inning as Cody Ross' two-out double to deep center that scored Uggla from first base.