The left-hander is 0-3 with a 5.21 ERA in three starts against Miami this season, and 10-1 with a 2.64 ERA against the rest of baseball in 14 starts.
"When we can't win with [Cliff] Lee and Hamels, that kind of tells you how things have gone," Phillies manager Charlie Manuel said. "We're trying to turn it around, of course, and get something going. We can get so close, yet we drift right back and get so far away."
Giancarlo Stanton drove in two of Miami's three runs, including a solo homer to left-center in the first inning that put the Marlins ahead 1-0.
With Jose Reyes at second, and first base open with two outs in the third, Hamels (10-4) elected to pitch to Stanton, who singled up the middle on a 1-1 offering that gave the Marlins a 2-1 lead.
"You don't always need to hit it 400 feet to get an RBI," said Stanton, who entered the game 5-for-22 with one dinger and two RBIs against Hamels. "Just put the bat on the ball, and it found a hole. [Hamels] doesn't make many mistakes. You have to take advantage when he does."
Miami tacked on an insurance run off Hamels in the fifth on Justin Ruggiano's bases-loaded sacrifice fly to the warning track in center. Reyes led off with a single to right and stole second. After Hanley Ramirez lined out to left, Hamels intentionally walked Stanton. Reyes and Stanton, however, pulled off a double steal.
"I'm glad it's a big ballpark," said Hamels, who pitched seven innings and allowed three runs on seven hits with five strikeouts. "They've been a tough team to pitch against. ... They've been able to put good wood on the ball and get the hits or the sac flies deep enough where they're scoring runs, and that's ultimately how you win a ballgame is by getting the runs in."
Hunter Pence remained on his torrid streak, homering for the second consecutive game -- a solo shot to left-center -- off Mark Buehrle (7-8) to trim the deficit to 3-2 in the seventh. It was Pence's 16th homer of the season.
Through eight games this year against the Marlins, Pence is batting .500 (15-for-30) with four dingers and eight RBIs. In the first two games of the weekend series, he has driven in three of the four Phillies runs.
Philadelphia took advantage of consecutive hits to open the second, tying the score at 1 on Shane Victorino's sacrifice fly to center that scored Carlos Ruiz.
Yet the Phillies remained plagued by their struggles with runners in scoring position, unable to tie the score in the fourth down, 2-1, when Victorino grounded into an inning-ending 1-6-3 double play. In the ninth inning against closer Heath Bell, Ruiz doubled to right-center with one out, but Pence struck out swinging and Victorino grounded out to short.
Over their past 108 at-bats with scoring chances, the Phillies have just 21 hits.
After the game, the Phils announced that Jim Thome was traded to the Orioles for two Minor Leaguers.
"Baseball's a game of you just keep plugging away," Thome said. "Look what the Cardinals did last year. I think that's kind of how it goes when you look how they did it.
The guys were great, the organization was great, there's a reason why this club has the reputation they have. You look through the room, there's winners up and down it."
Hamels, who becomes a free agent this winter, said the front-office move hasn't changed his stance. He said he's "not even thinking about that" right now.
"Sometimes it's hard to get things rolling in the right direction, and you've got to keep fighting and you feel like nothing's going to bounce your way, and nothing does bounce your way," Hamels said. "But the good teams know how to survive, so that's just a matter of us digging deep and keep trying to play and see what happens.
"Obviously we're not in first place or close to first place, so we have a lot of games that we really have to play hard. We have to go out and play hard. It's a matter of being able to get the wins, and we're not. I think we're all kind of searching. We don't like losing, I don't like losing, so it's a matter of just trying to go out there and doing your part."