PHILADELPHIA (AP) — The New York Mets erased a six-run deficit with seven runs in the ninth inning, capping the rally with Starling Marte’s tiebreaking double to beat the flabbergasted Philadelphia Phillies 8-7 Thursday night.

With the Mets trailing 7-1, Marte led off the inning with an infield single against James Norwood and scored on Francisco Lindor’s two-run homer. Mark Canha added an RBI infield single that clanked off pitcher Corey Knebel, and J.D. Davis had a pinch-hit RBI double to rally the NL East-leading Mets.

Brandon Nimmo then lined a tying, two-run single to center off Knebel. He came around to score when Marte ripped a double off the wall in center field.

It’s the first time New York trailed by at least six runs in the ninth and won since Sept. 13, 1997, when Carl Everett hit a tying grand slam with two outs in the ninth and the Mets went on to beat the Montreal Expos in extra innings.

Bryce Harper and Nick Castellanos homered for the Phillies, and Aaron Nola pitched seven sharp innings. The Phillies have lost five of six.