PHILADELPHIA — Scott Kingery broke an eighth-inning tie with a three-run double, and the Philadelphia Phillies beat the Mets, 5-2, on Sunday night, averting a three-game sweep.

Brad Miller hit a solo homer and a double for the Phillies, who pulled within two and a half games of the Chicago Cubs for the second National League wild card.

Pete Alonso hit his 43rd homer, and Wilson Ramos extended his hitting streak to 25 games with a fourth-inning double for the Mets, who are four games behind the Cubs.

After the Mets tied the score at 2-2 on a wild pitch in the top of the eighth, Bryce Harper led off the bottom half with a single against Daniel Zamora (0-1), who had just been recalled from the minors. Jeurys Familia walked Rhys Hoskins before Miller flied out to deep center, allowing both runners to advance. Cesar Hernandez was intentionally walked, loading the bases for Kingery, who lined a 1-0 pitch into the left-center gap.