PHILADELPHIA — The possibility of sweeping the Phillies and slicing another game from their wild-card deficit hovered for the Mets on Sunday, but then the bottom of the eighth inning struck.

Daniel Zamora, a lefty reliever who had been recalled from Triple-A Syracuse earlier in the day, allowed a single to Bryce Harper leading off the inning. Enter Jeurys Familia, who for all his recent improvement still hasn’t shown he can be trusted in a big spot. Scott Kingery added to that reality by delivering a bases-loaded double against Familia that scored three runs in the Mets’ 5-2 loss at Citizens Bank Park.

“I just haven’t been doing my job this year,” Familia said through an interpreter. “It’s not that I get nervous or I’m out of control or try to do too much, it’s just that I couldn’t get the job done.”

The Mets remained four games behind the Cubs in the race for the NL’s second wild card. The Cubs lost 4-0 earlier in the day to Milwaukee.

Upon entering with it tied 2-2, Familia walked Rhys Hoskins, retired Brad Miller and intentionally walked Cesar Hernandez to load the bases. Kingery followed with a shot to the left-center gap that scored all three.

Manager Mickey Callaway had limited bullpen options because Justin Wilson and Seth Lugo were both unavailable and another trusted reliever, Luis Avilan, had already worked in the game. Callaway indicated Edwin Diaz only would have been a possibility in the eighth inning if the Mets had the lead.

“Familia is a premium ground-ball guy and we’re looking for a ground ball there,” Callaway said.

Brandon Nimmo came sprinting home from third on Hector Neris’ wild pitch in the eighth to tie it 2-2. Neris bounced a fastball in the dirt on ball four to Pete Alonso, after the Mets had used a Todd Frazier single and walk to Nimmo in rallying against Mike Morin. Luis Guillorme’s sacrifice bunt moved pinch-runner Rajai Davis to third and Nimmo to second before Jeff McNeil hit a grounder to first that resulted in Davis getting thrown out at the plate (umpire Joe West was slow with the out call after he became entangled with Davis). But Neris let the Mets off the hook by burying the 3-1 pitch to Alonso.

Marcus Stroman gave the Mets six solid innings in which he allowed two earned runs on seven hits with six strikeouts and one walk. It was the first quality start in six tries by the right-hander, who arrived in a trade with the Blue Jays on July 28.

“They came out swinging early — from the first pitch, literally,” Stroman said. “I still have to be better. Maybe my pitch selection in the second [inning] I need to be a little bit more aggressive, but I felt pretty good overall.”

Stroman surrendered two runs during a rocky second to put the Mets in a 2-1 hole. Miller homered leading off the inning before Kingery singled with one out and Adam Haseley walked. Stroman attempted a pickoff play at second with nobody covering and threw the ball into center field, allowing the runners to advance. Corey Dickerson’s two-out RBI single brought in the run.

Michael Conforto’s strong throw to the plate nailed Dickerson attempting to score from second on Hoskins’ single, ending the first inning.

Alonso’s 43rd homer of the season gave the Mets a 1-0 lead against Zach Eflin in the first. The blast was Alonso’s first in this ballpark, which is among baseball’s premier launching pads.

Wilson Ramos doubled off the third baseman Miller’s glove in the fourth and extended his hitting streak to 25 games. He needs a hit in his next game to match David Wright for the second-longest hitting streak in club history. Moises Alou owns the Mets record with a 30-game hitting streak.

“We had plenty of opportunities to cash in on some runs,” Alonso said. “We didn’t do that, but we did win the series and we need to come out and play real well and try to take a series or sweep in Washington.”

Purchase event tickets to The Amazin’ 1969 New York Mets: A World Championship for the Ages presented by The Paley Center for Media and New York Post. Enter promo code: NYPOST to unlock tickets only available for Post readers.