MIAMI — Carlos Santana stepped on first base Sunday afternoon, believing he had recorded the final out in the fifth inning and put the brakes on a budding Marlins rally. But the Phillies first baseman had lost track of the outs. Instead of attempting a double play, he had only recorded the second out of the inning. The rally marched on.

A batter later, Edubray Ramos thought he, too, ended the inning when Martin Prado stared at his full-count fastball. But home plate umpire Todd Tichenor ruled that pitch was ball four. Again, the Marlins' rally continued. And the Phillies' afternoon — which started with such promise — would soon be doomed, as they lost 10-5.

The Phillies used three pitchers in the fifth inning to record three outs, allow eight runs and blow a five-run lead. They twice thought they escaped the inning, and twice they were wrong. The Phillies have lost three of their last five games, but they will still enter the all-star break in first place in the National League East for the first time since 2011.

>>READ MORE: Is Chase Utley a Hall of Famer?

This was not the prettiest series, manager Gabe Kapler said. But the Phillies have something to cling to as they prepare for the second half.

"I think that's going to feel good to our club," Kapler said. "Our club needs a break. This is going to be a good, solid break for us."

Santana might have been able to turn an inning-ending double play on the grounder he fielded had he known how many outs there were. J.T. Riddle, not exactly the fastest runner, was hardly out of the batter's box when Santana plucked the sharp grounder near first base. Scott Kingery was waiting at second for the throw and would have been able to throw back to Santana for a chance to get Riddle.

Santana said he didn't think there was a chance for two. Kapler agreed.

"It's tough. The way I saw it, it was probably a one-out play," Kapler said. "Obviously, losing track of the outs is something that can't happen. But [Santana] is one of our most locked-in and focused players most of the time. I think he's earned a pass on this one."

To start the fifth, Enyel De Los Santos was blitzed for four quick runs from six batters, two of whom homered. Ramos entered with one out, and picked up the second on Riddle's ground out before he thought he froze Prado. Tichenor's call, Ramos said, "changed the inning completely."

The walk to Prado loaded the bases. Miguel Rojas followed with a two-run single and the Marlins had erased a five-run deficit to take a 6-5 lead. Ramos allowed another single before he was lifted. Adam Morgan gave up a two-run single to Justin Bour to cap the Marlins' eight-run inning. The Phillies, an inning after leading by five runs, were suddenly down three.

"I thought we were going to be out of the inning with that called strike but he called it a ball," Ramos said. "Everything changed. There's nothing I can do about it."

The Marlins' rally was hard to imagine just an inning earlier, when the Phillies seemed set to be cruising into the all-star break with a rout after building a five-run lead. They had scored just two runs in the previous 24 innings before Maikel Franco and Scott Kingery laced RBI singles and Cesar Hernandez slammed a three-run triple.

The lineup — outside of a 17-run outburst against the Pirates — had mostly limped through the 11-game road trip. Perhaps they were ending it with a surge. But that would be all the Phillies could muster. They did not get another hit. All five runs and all four hits came in the fourth inning. The Phillies totaled just two base runners in the other eight innings.

The game looked ready to be broken open when Hernandez slid into third base and the fifth run of the inning crossed home plate. And it was. But it was the Marlins who broke it open.

The Phillies stayed in first place, but they did not enter the break the way they wanted to.

"You probably know me by now. I'm kind of an optimist, right," Kapler said. "So I'm going to take away all of the positive things that we did in the first half. The fact that we are in first place. We do have a tremendous home record. We've had a really, really spectacular first half. I'm really proud of our guys. That's what I'm going to be thinking about and I think that clubhouse will be thinking about."