PHILADELPHIA (AP) -- Maybe the Phillies will manager to avoid their first 100-loss season since 1961.
Freddy Galvis had two RBIs and scored the go-ahead run on a wild pitch in the sixth inning, helping Philadelphia defeat the New York Mets 7-5 on Wednesday night.
The last-place Phillies (61-97) need to win two of their last four games to avoid the century mark.
"I wake up every day knowing I don't want to lose 100 games," Phillies reliever Justin De Fratus said. "That wouldn't be a nice thing to sit on in the offseason."
De Fratus hit Mets slugger Yoenis Cespedes on the ring and middle fingers with a pitch in the third inning, leading to a testy game.
"I felt pain when I first got hit," Cespedes said through a translator. "I was relieved when X-rays came back negative."
"That's always scary," added Mets manager Terry Collins. "Very relieved he's OK."
De Fratus said it was a sinker that got away.
"I hope he's OK," he said. "We don't want to be doing them any favors, but that's not the way I want to do it. I feel bad about it."
Acquired at the July 31 trade deadline from Detroit, Cespedes is batting .287 with 17 homers and 44 RBIs in 54 games with the Mets. Overall, he has set career highs this season with 35 home runs and 105 RBIs.
He exited in the third inning after being hit, but returned to the dugout in the sixth when the benches started to empty following a high-and-tight pitch.
Cespedes' replacement, Kirk Nieuwenhuis, later was hit. After that, Odubel Herrera of the Phillies was plunked in the back.
The three hit batters prompted a warning to both teams before Hansel Robles' head-high pitch sent Philadelphia's Cameron Rupp to the ground in the sixth. Robles and Collins were ejected.
"It was a fastball that got away," Robles said.
Said Collins, "You can't miss that bad up around the head."
Daniel Murphy and Michael Conforto homered for the NL East champion Mets, who remained one game ahead of the Los Angeles Dodgers for home-field advantage in the Division Series. The Mets hold the tiebreaker in the event the teams finish with identical records.
Ken Roberts (1-1) retired one batter. Seven Phillies relievers combined to pitch 8 1-3 scoreless innings, capped by Ken Giles working the ninth for his 15th save in 19 chances.
Bobby Parnell (2-4) faced three batters and retired none of them.
The teams combined to use 17 pitchers in the 3-hour, 59-minute game.
"It was an ugly game," Collins said. "We have to get rekindled here. We'll get it going."
Darin Ruf had a two-run double for the Phillies.
The Phillies went ahead with three runs on one hit in the sixth, with Galvis scoring on Carlos Torres' wild pitch.
Conforto's two-run homer with two outs in the first made it 5-0 and finished Alec Asher.
Logan Verrett made a spot start for the Mets in place of Steven Matz and surrendered three runs on four hits in 4 1-3 innings. Matz originally was slated to pitch, but the rookie's outing was pushed back a day after he woke up Tuesday with a sore back.
Collins said prior to Wednesday's game that the back issue was lingering and Matz would not appear on Thursday, either. After the game, Collins indicated that Matz was feeling batter following treatment and medication for muscle spasms.
Philadelphia's Aaron Altherr singled, extending his streak of reaching base safely to 10 straight games.
Mets: SS Wilmer Flores left the game in the fourth inning with lower back stiffness.
Phillies: Manager Pete Mackanin said prior to Wednesday's game that 1B Ryan Howard, out since Sept. 14 after getting hit on the left knee by a ball at first base, may not play the rest of the season. ... 3B Maikel Franco plans to rejoin the team for their season-ending weekend series against the Marlins, which begins Friday. Franco, who has been on the DL since Aug. 12, is scheduled to arrive in Philadelphia late Thursday morning.
RHP Jerad Eickhoff (2-3, 3.07) takes the mound for the Phillies in the conclusion of the three-game series at 12:05 p.m. on Thursday. The start time was changed from 7:05 p.m. due to the impending storms in the Northeast expected from Hurricane Joaquin. LHP Sean Gilmartin (3-1, 2.58) will start for the Mets.