MIAMI -- Near-elation turned into more frustration for the Marlins on Thursday night.

Carlos Ruiz belted a homer off Will Ohman in the top of the 10th inning to lift the Phillies to a controversial comeback win, 5-4, over the Marlins in front of 19,121 at Sun Life Stadium.

Ruiz, who has 13 RBIs over his past nine games, led off the 10th inning with a home run to left. More drama ensued two batters later, when Ben Francisco lifted a long shot to left that sailed a few feet foul, but the umpires used instant replay to determine if it was a homer.

That call went the Marlins' way. Another one did not, and it proved pivotal.

Along with witnessing a two-run lead disappear in the ninth inning, the Marlins also dealt with a controversial call by third-base umpire Bob Davidson. With Hanley Ramirez on second base and one out, Gaby Sanchez pulled a hard grounder down the third-base line off Ryan Madson. The ball straddled the line, and as it went over the bag, Davidson signaled foul while the ball landed inches fair past the base.

Rather than celebrate their eighth walk-off win of the season, the Marlins watched as the play was wiped out. Manager Edwin Rodriguez, livid, argued with Davidson, who kept telling the manager that the ball was foul.

"I've been in this game for 30 years, and I have the highest respect for the umpires," said Rodriguez, who pleaded his case hard. "That was the worst call I've ever seen in my 30 years in baseball. That ball was a fair ball by six inches. He was never even looking at the play."

If the ball is ruled fair while crossing the bag, it is a fair ball. If it is to the foul side of the bag, it is determined foul.

TV replays showed that the ball landed inches in fair territory past the bag, but Davidson didn't follow the ball as it struck the ground.

"I was right on top of it and it was wide of the bag, that's all -- I had it foul," Davidson told a pool reporter after the game. "In my opinion, where it goes over the bag, you can't tell. After a bounce, it came an inch or two on the fair side, but ... it was very close. But I'm right there. I know what I saw.

"I'm very confident I got it right. What the ball did when it went past me is irrelevant. ... I understand that's the winning run, but in my opinion it was foul, and there's no replay that you can really see what the ball does over the bag -- and that's what's important. But I know what I saw."

From Rodriguez's vantage point, he saw it differently.

"He was telling me that it wasn't even close and that it was a foul ball," Rodriguez said of his discussion with Davidson. "I knew he never even saw the ball. I was telling him, 'Ask for help.'"

Seeking a second opinion, Rodriguez urged Davidson to ask home-plate umpire Tim Tschida what he saw.

"He never asked for help," Rodriguez said.

Feeling victory taken away by a call, Rodriguez said he would favor instant replay on plays that determine the outcome of a game. Replay is used only on close calls that determine home runs.

"If a play is going to decide who wins or loses the game, then they should go and check the play," Rodriguez said. "Any play."

From Sanchez's perspective, it was difficult to regroup after what would have been the Marlins' fifth walk-off victory since the All-Star break.

When he stepped back into the batter's box, Sanchez ended up striking out.

"It's tough -- I feel like mentally, it shouldn't be like that, but I feel the next pitch, I'm kind of thinking about the last ball," Sanchez said. "It's definitely tough trying to pull yourself back and say, 'That just passed, and still give a good AB against Madson because he's tough.' He's got a great changeup and he's not afraid to throw it on any count."

-- Third-base umpire Bob Davidson

Sanchez eventually struck out, and Madson worked out of the jam by intentionally walking Dan Uggla before striking out Cody Ross to force extra innings.

"[Davidson] made the call -- there is nothing we can do about that," Sanchez said. "He had a good look at it. He made it, and he stuck to it. He made it. There's nothing I can really do right now.

"It's going to happen. Umpires are going to miss calls. Hitters are going to miss pitches, and pitchers are going to miss locations. It's all a part of the game. ... We can't just fault that one play. We had the lead. We were in position to win the ballgame."

"The ball never landed in foul territory," Marlins owner Jeffrey Loria said. "Dreadful."

Being denied of a dramatic hit added more frustration to a rough night. The Marlins have now lost four straight, matching a season high, and they fell to 53-55.

Phillies manager Charlie Manuel feels the Marlins can still make an improbable run.

"This was good for us and it kind of hurt them, but they're not out of it," Manuel said. "If they can make it until September [being] seven or eight games out, they're playing in the division and they have a chance."

To get back to .500 and make a charge, the Marlins must shore up their defense and lock down games they have in hand.

Carrying a two-run lead into the ninth inning, right-hander Leo Nunez saw his string of 10 straight converted saves come to an end when the Phillies drew even on an RBI double by Raul Ibanez and a run-scoring single by Jayson Werth.

Placido Polanco reached on Ramirez's throwing error to get the inning started. Nunez allowed a single to former Marlins infielder Ross Gload. After the lead was lost, Florida was able to keep the game tied when Ibanez was tagged out at the plate on Domonic Brown's fielder's-choice grounder to first.

Nunez then picked Werth off second base, and Brown was caught trying to steal second, keeping the score tied at 4.

Limited to three runs in the first two games of the series, the Marlins at last enjoyed a big inning when they batted around and scored four times in the seventh.

Donnie Murphy delivered a ground-rule double that brought home a run, making him 5-for-12 with seven RBIs as a pinch-hitter this season. Ramirez was intentionally walked to fill the bases, and Logan Morrison drew a walk to tie the game. And Sanchez delivered a two-run single that put Florida in front, 4-2.

"I still believe we're in it -- I believe we can make history here," Rodriguez said. "I really believe that. If we keep playing the way we've been playing, we'll be fine.

"The Phillies battled, and we battled. It was a very good game -- until that call."