PHILADELPHIA — Five years is a long time between wins. That’s why this one meant so much to reliever Frank Herrmann.

Pinch-hitter Jimmy Paredes singled home the winning run with one out in the 13th inning to give Herrmann and the Philadelphia Phillies a 4-3 victory over Miami on Friday night, dropping the Marlins (73-74) five games behind the New York Mets for the second NL wild card.

Herrmann, who spent much of the season pitching in the minors for Philadelphia, tossed two scoreless innings and earned his first major league win since 2011.

“It’s nice to contribute,” Herrmann said. “Things haven’t gone as well as I would have hoped since being up here, but I feel like on the whole this season I’ve thrown the ball pretty well, so it’s nice to express that.”

Ryan Howard homered to spark a three-run rally for the Phillies in the sixth. Cameron Rupp and Odubel Herrera hit back-to-back doubles to tie the game, and Herrera scored on an RBI groundout by Aaron Altherr.

Derek Dietrich pulled the Marlins even with his first career pinch-hit homer in the eighth, connecting off Edubray Ramos.

“Obviously, our guys really battled tonight, but when you get to the root of it, we left a lot of people out there,” Miami manager Don Mattingly said. “We left some guys out there with sacrifice-fly situations or if someone hits a ball in a gap there somewhere, you put a game like this away. We just weren’t able to do it.”

Herrmann (1-2) had not won in the big leagues since pitching four innings in relief during a 16-inning game for the Cleveland Indians on Aug. 31, 2011.

The last three of his five career wins have come in extra innings.

Herrmann said his teammates in the minors were calling him “The Snake” because a handful of times he would sneak into games in extra innings and steal the win.

“To get wins like this mean a lot to me,” he said.

It was the longest game of the season for the Phillies, both in innings and time of game (4 hours, 43 minutes). But it was worth the wait for Paredes, who got his chance with the bases loaded in the 13th.

With the Marlins playing five infielders to try and cut down a run at home plate, Paredes lined a pinch-hit single off A.J. Ramos (1-3) to right field, scoring Peter Bourjos.

“I took advantage of that defense,” Paredes said. “I noticed there was nobody in center field, so I just tried to put the ball in play in the middle.”

Philadelphia’s bullpen did a fine job in relief of starter Adam Morgan. The relievers allowed just one run in 8 2/3 innings. Morgan was lifted after 4 2/3 innings. He gave up two unearned runs, seven hits and two walks.

Martin Prado had three hits, two doubles and an RBI for Miami. Dee Gordon got three hits and stole two bases.

Bourjos opened the bottom of the 13th with a single and went to third on Herrera’s one-out single. Freddy Galvis walked to load the bases, and Paredes lined a single over the drawn-in infield.

The teams struggled to get runners home and also had difficulty making contact at times. They combined to leave 24 runners on base and struck out a combined 30 times.

The Marlins left the bases loaded in the 11th inning and left two runners on base four other times in the game.

Likely playing in his final few games with the Phillies in front of the home crowd, Howard connected leading off the sixth. He tied Maikel Franco for the team lead with his 22nd home run.

“Hopefully, he can continue over the last 14 games,” Phillies manager Pete Mackanin said. “Not that he is going to play every game, but it’s good to see him do that — and it’s good for the fans.”

Howard also pulled even with Tony Perez and Orlando Cepeda for 70th place on the career list with homer No. 379.

Rupp followed with a double that chased Marlins starter Tom Koehler. Herrera tied the game with a double off reliever Mike Dunn.

STATS

Prado is hitting .318 against the Phillies this season with eight doubles and eight RBIs. … Koehler made his 30th start, joining Dontrelle Willis and Scott Olsen as the only Marlins pitchers to reach that plateau in three consecutive seasons. … Morgan did not allow an earned run, the 14th straight start by a Phillies pitcher in which they yielded three runs or fewer. That’s the longest streak for Philadelphia since a 17-game stretch in July 2000. … Galvis has gone 50 consecutive games without an error. He leads NL shortstops in fielding percentage (.996) since the All-Star break.

TRAINER’S ROOM

Marlins: OF Giancarlo Stanton made his first start since a groin injury on Aug. 9. He had made five pinch-hit appearances since returning last week. With the team limiting his innings, Stanton went 0 for 2 with two walks and grounded into a double play before being replaced in the sixth.

Phillies: Top prospect J.P. Crawford, thought to be a candidate for a September call-up, had arthroscopic surgery on his left knee to remove loose bodies. The team said Crawford is expected to be ready for spring training.

UP NEXT

Marlins RHP Jose Urena (4-6, 4.89 ERA) opposes Phillies RHP Jeremy Hellickson (11-9, 3.76) on Saturday night.