Cameron Maybin nearly ended it with one swing, launching a long fly ball that curved foul by a few feet.
"I knew it had a chance," Maybin said. "I was talking to it, but it wasn't listening."
No matter. Maybin followed his near miss with a triple and came home to score on Yadiel Rivera's pinch-hit single in the 10th to give the Marlins a 2-1 victory over the Phillies and extend their winning streak to four in a row -- the longest winning streak in the National League.
The Marlins have now won six of their past seven games.
Sign Up and Save
Get six months of free digital access to the Miami Herald
The rarely used Rivera stepped to the plate with a .100 average (2 for 20) but smacked a hard single to right off Yacksel Rios to give the surprising Marlins another win and a chance to sweep the Phillies when they end their series on Wednesday.
"It felt great," Rivera said, who will celebrate his 26th birthday on Wednesday.
Rivera said it was the first walk-off hit of his major league career, all of spent with the Brewers before the Marlins signed him to a minor-league deal with an invitation to spring training.
"The best feeling, my first walk-off," Rivera said.
Like everyone else on the Marlins, Rivera thought Maybin had ended it earlier in the 10th with his deep drive to left.
"We all thought it a a home run," Rivera said. "And then he came up with a big triple and changed the game for us."
It took a while for the Marlins to get going on Tuesday.
Phillies starter Zach Eflin took a perfect game into the sixth before Miguel Rojas broke it up with a leadoff bloop double. that dropped between two fielders. But even though the Marlins managed to get on the scoreboard with Justin Bour's game-tying, pinch-hit solo homer, it was a missed opportunity of an inning for them.
Rojas was thrown out in a rundown on Lewis Brinson's easily playable bunt a few feet in front of the plate, and Brinson was picked off first right before Bour went deep with his fifth home run of the season.
It was another fine outing for Jarlin Garcia, who has emerged as the Marlins' premier starter. Garcia went six innings, allowing a run on five hits. It was only the second run allowed by Garcia in his four starts covering 23 innings.
Counting his relief innings, Garcia now has a 1.09 ERA.
It became a battle of bullpens once Garcia and Eflin came out after the sixth, with neither side giving in.
The Phillies loaded the bases off Junichi Tazawa in the 10th. But Maikel Franco lined to Rojas to snuff out the threat.