MIAMI — With one swing, Freddy Galvis ended the Philadelphia Phillies’ scoring drought. Soon their losing streak was over, too.

Galvis hit a two-run homer to snap a streak of 18 consecutive scoreless innings for the Phillies, who stopped a six-game slide with a 6-2 victory over the fading Miami Marlins on Monday.

“I’m just happy to get a couple of runs,” Philadelphia manager Pete Mackanin said.

The Phillies’ run total was their highest since Aug. 14. They rank last in the majors in runs, and managed only 11 while going 0-6 during a homestand last week.

“Everything was going weird when we were back home,” Galvis said. “We’d get men on base and we didn’t drive them home. This win is going to be good for us.”

Now it’s the Marlins who are desperate for a victory. They’ve lost four in a row and are 11-22 since Aug. 1, with their thin depth an issue as injuries mount.

“We knew that we were going to be challenged depth-wise,” manager Don Mattingly said. “We needed a little bit of luck and everything to fall in its slots. In the past month and a half, it has probably fallen the wrong way, and it has put us in a bind.”

Miami fell two games below .500 for the first time since April 27 and could be headed for a seventh consecutive losing season.

Philadelphia’s Jerad Eickhoff (10-13) allowed the first two batters to score and then settled down to pitch six innings. The Phillies have won five of his past six starts, and he overcame a 2-8 start to reach the 10-win mark for the first time.

“Anytime you get double-digit wins, it’s a huge testament to what we as pitchers try to do,” Eickhoff said.

Eickhoff and three relievers combined to retire the final 15 Marlins in order.

Jake Esch (0-1) allowed three runs in five innings in his second major league start.

“It’s a positive step in the right direction for me personally,” Esch said. “But it ended up as a loss for the Fish again. So I have to be a little bit better.”

The Phillies managed only one hit off Esch until the fifth, when they scored three runs. Galvis’ upper-deck homer made it 2-all, and Peter Bourjos tripled and came home when shortstop Miguel Rojas mishandled a one-out grounder for an error.

Bourjos had three hits and scored twice. Jimmy Paredes had a pinch-hit, two-run single in the seventh.

The Marlins mustered only six hits. They haven’t homered at home since slugger Giancarlo Stanton went on the disabled list Aug. 14 with a strained groin.

GALVIS’ POWER

Galvis has 16 homers, but his on-base percentage is only .270.

“We want better than that,” Mackanin said of the latter stat. “It’s nice he’s capable of hitting the long ball, but I want him to be more of a line-drive hitter. Consistency and quality at-bats are what we’re looking for.”

POOR COMMAND

Marlins right-hander Austin Brice made two throwing errors — one to first base and one to second — in the Phillies’ three-run seventh.

TRAINER’S ROOM

Marlins: RF Stanton might be available to pinch-hit soon, Mattingly said. “He’s moving pretty good,” Mattingly said. “He’s feeling good. He has been able to swing the bat. It’s just a matter of what he can do, and how safely he can do it.” … 1B Justin Bour (right ankle) might be activated Tuesday, Mattingly said. … Rojas left with a left groin strain, and his status is day to day.

UP NEXT

Marlins RHP Jose Urena (3-5, 5.40 ERA) faces Phillies LHP Adam Morgan (1-9, 6.21 ERA) on Tuesday. Over his past three starts, Urena is 2-1 with a 2.04 ERA.