MIAMI -- One good eye was all Mike Stanton needed to hit his first walk-off homer.
The young slugger has struggled with blurry vision, especially at night. He saw a doctor before the game and was told the problem should clear up with the help of drops, but he has another exam scheduled next week.
"I've felt it for the last month-and-a-half," Stanton said. "It's either going to get better or stay the same. I've had good games, I've had bad games with it."
The Marlins overcame an early 4-0 deficit and averted a series sweep when Stanton pulled a 2-1 slider from Danys Baez (2-4) into the seats in left for his 17th home run this season and the first walk-off of his career.
Stanton had been hitless in his previous four at-bats, striking out twice and grounding into a bases-loaded double play. He has struck out 15 times in the past eight games.
"It was good to see Mike go deep," manager Jack McKeon said. "It's got to lift his confidence up. He's had a little struggle. Maybe that will get him going."
The Marlins won for only the second time in their past 17 games decided by one run. They ended a streak of seven consecutive defeats to the Phillies, who lost for only the fifth time in 26 games at Miami since September 2008.
"Any time you can get a win against the Phillies, it's going to mean a lot," Florida outfielder Logan Morrison said. "If it would happen more often, it would mean more. We've got to figure out a way to get it done."
Florida improved to 4-10 in extra-inning games.
A baserunning mistake by Domonic Brown cost Philadelphia a run in the sixth. He tripled to lead off the inning, but the Marlins appealed and he was ruled out for failing to touch second base. Mayberry followed with a homer off Mike Dunn.
"I was trying to go so fast, all I was thinking was getting to third," Brown said. "I might have touched it with my heel, but I couldn't tell. I think I missed it, though. It cost us the game."
"That's the difference when everybody pulls a little bit, and not just one guy," Ramirez said. "That's why the Phillies always do good. They don't only have one guy."
Anibal Sanchez of Florida failed to make it to the fifth inning for the second straight start. He was lifted for a pinch-hitter in the fourth trailing 5-3.
"We won, but that's not the game I want to throw," he said.
Philadelphia starter Kyle Kendrick pitched five innings and allowed three runs, one earned.
Mayberry, recalled Tuesday from Triple-A, hit a two-run homer in the second inning and a solo homer in the sixth. The multihomer game was the first of his career, and he has five home runs this season.
The Phillies' first five runs scored with two outs.
Morrison's homer off David Herndon in the sixth cut the Phils' lead to 6-5. Florida tied the game in the seventh when Infante tripled and scored on a single by Ramirez.
The Marlins went on to load the bases with one out, but Drew Carpenter got Stanton to hit into a double play.
Florida scored three runs in the third, with two unearned because of an error on right fielder Brown. After Anibal Sanchez singled and Emilio Bonifacio walked, Gaby Sanchez hit a sharp single and continued to third when Brown misplayed the ball. Ramirez followed with an RBI infield hit.
"We made a lot of mistakes, mentally and physically," Phils manager Charlie Manuel said. "They capitalized on everything we did wrong."
Utley improved his lifetime average against Sanchez to .484 (15 for 31). ... Mike Cameron, a 16-year veteran acquired by Florida on Tuesday in a trade with Boston, pinch-hit in the eighth and fouled out. ... The Phillies fell to 14-2 on Wednesdays.