One night after losing their 100th game of the season, the Marlins let a two-run lead slip away and then pulled out the victory.
Philadelphia tied it in the seventh on RBI singles from Freddy Galvis and Cesar Hernandez, but Miami quickly regained the advantage.
Ruggiano drew a one-out walk in the eighth off Ethan Martin (2-5), went to third on a single by Placido Polanco and scored on a fielder's choice grounder off the bat of Adeiny Hechavarria.
Chad Qualls (5-2) came up with the win after retiring the only man he faced in the eighth. Steve Cishek gave up a leadoff bunt single in the ninth, but the runner never advanced past first base as the Miami closer earned his 33rd save.
'SNL': 'Anchorman 2' cast, One Direction sing 'Afternoon Delight' [VIDEO]
Reindeer recovered after escaping from Santa during lighting ceremony