SAN DIEGO -- Theoretically, Jake Peavy pitched well enough to win.
Realistically, though, the San Diego Padres simply couldn't score enough runs for their All-Star ace.
Kim and four relievers combined to hold the anemic Padres' offense to three hits as the Marlins split the four-game series with the NL West leaders.
"We got three runs," Marlins manager Fredi Gonzalez said. "That's pretty good for any starting pitcher. We just happened to hold them to two."
San Diego's Nos. 3-5 hitters were also 0-for-10, with seven strikeouts. Mike Cameron did reach base twice, on a walk and when he was hit by a pitch, and scored once. The Padres were 0-for-8 with runners in scoring position.
San Diego's No. 3 hitter, Adrian Gonzalez went 0-for-4 with three strikeouts to extend his slump to 4-for-47 since June 23. He'll sit out Friday night's game against the Atlanta Braves.
"It's been frustrating for the last three weeks," Adrian Gonzalez said.
The Padres lost a one-run game for the 17th time, including 11 at pitcher-friendly Petco Park.
"I think the potential's there. It's not happening right now," manager Bud Black said. "But I do think we're seeing signs of guys swinging the bats better. We're hoping to turn it around. We've won those low-scoring games, and we think we'll continue to win them. I know the guys aren't happy about it, but they're going to keep working."
Kim (4-4) allowed two runs and three hits -- all for extra bases -- in 6 1/3 innings, struck out seven and walked two.
Kevin Gregg pitched a perfect ninth for his 17th save in 18 chances, and his second this series. The Marlins' bullpen didn't allow a hit in 2 2/3 scoreless innings.
The game ended when Hermida, the right fielder, caught Jose Cruz Jr.'s drive against the wall.
"I was a little nervous at first," Gregg said. "I haven't seen him turn on a pitch like that in all the video I watched. Luckily, it went to the deepest part of the park."
Peavy (9-3), a candidate to start Tuesday night's All-Star Game at San Francisco, gave up three runs and five hits in seven innings. He struck out six and walked three.
"I've got to be better than I was to win," he said. "It's no fun losing."
In his last three starts, Peavy has two losses -- the other was to Boston's Josh Beckett -- and a no-decision against Brad Penny in the Padres' 3-1, 12-inning win at Los Angeles on Saturday night. Penny is the other candidate to start the All-Star Game.
Kim, who matched his longest outing of the season, hadn't won since May 28 at the Chicago Cubs. He had two losses and four no-decisions in his next six starts.
He was chased after Michael Barrett doubled down the right-field line to score Cameron from first, pulling the Padres to 3-2.
Kim also was called for a balk, but it didn't figure into the scoring.
"The mound was a little higher than I expected, so my control was a little off," Kim said. "But I settled down and made an adjustment."
Fredi Gonzalez said the Marlins' bullpen was "unbelievable."
"They held the fort down," he said. "It's been that way all year. I know we hit a little bump, but if it wasn't for them, we'd be in a real difficult situation as far as our record."
The Marlins quickly overcame a 1-0 deficit.
Peavy walked Josh Willingham with one out in the second and allowed Hermida's double to left. Both scored on Treanor's single up the middle.
Hermida made it 3-1 two innings later when he homered to center on an 0-2 pitch from Peavy. It was his eighth.
Brian Giles walked leading off the Padres' first and scored when little brother Marcus hit a flare into right field that went for a triple. The ball rolled under the bench in the Marlins' bullpen and Hermida had a hard time digging it out.
- Padres RHP Chris Young dropped the appeal of his five-game suspension for his part in a bench-clearing brawl at Chicago on June 16, and began serving the penalty on Thursday. His suspension will span the All-Star break -- four games before it and one after it.
- Young won the online voting for the final spot on the NL All-Star team. The Padres put on a last blitz by playing messages on the video board from Peavy, All-Star closer Trevor Hoffman and Mayor Jerry Sanders encouraging fans to vote via text message.
- Marlins OF Eric Reed was recalled from Triple-A Albuquerque to take the roster spot of RHP Josh Johnson , who went on the 15-day DL on Wednesday night with stiffness in his right forearm.