NEW YORK — Wilmer Flores hit a go-ahead, three-run homer and the New York Mets rallied past the Washington Nationals 9-7 on Thursday night in the opener of a pivotal four-game series between the top teams in the NL East.

Travis d’Arnaud, Jose Reyes and Asdrubal Cabrera also went deep for New York in a slugfest that featured eight home runs – the most in the eight-year history of Citi Field.

The second-place Mets improved to 7-1 on their 11-game homestand leading into the All-Star break and shaved Washington’s division lead to three games – two in the loss column.

Daniel Murphy homered and drove in three runs, his latest big performance against the Mets since the defending NL champions let him leave as a free agent in the offseason. Bryce Harper, Clint Robinson and Anthony Rendon all added solo shots.

CARDINALS 5, PIRATES 1: Stephen Piscotty hit a three-run home run and Randal Grichuk also went deep to help St. Louis win at home – avoiding a four-game sweep and end the Pirates’ season-best seven-game winning streak.

Adam Wainwright (8-5) worked seven effective innings for St. Louis, which reclaimed second place in the NL Central by a half-game over Pittsburgh to end a rough 4-5 homestand.

AMERICAN LEAGUE

ROYALS 4, MARINERS 3: Salvador Perez ripped a double off the wall in the ninth inning, scoring Whit Merrifield and Jarrod Dyson to give Kansas a win at home.

Merrifield doubled off Steve Cishek (2-5) leading off the inning, then Kendrys Morales got plunked on the foot. Dyson came in to pinch run and Eric Hosmer struck out before Perez lined a shot off the wall in center.

ANGELS 5, RAYS 1: Albert Pujols and C.J. Cron drove in runs to back starter Hector Santiago and lead visiting Los Angeles over struggling Tampa Bay.

Pujols snapped a scoreless tie with a sixth-inning single off rookie Blake Snell (1-4). Cron followed with a RBI grounder that the Rays, who have lost 19 of 22, were unable to turn into an inning-ending double play.

BLUE JAYS 5, TIGERS 4: Troy Tulowitzki drove in the tying and go-ahead runs with a bases-loaded single in the eighth inning as Toronto pulled off a rally at home for its season-best sixth consecutive victory.

Tulowitzki finished 2 for 4 with a walk and three RBI.

Tulowitzki is batting .338 (22 for 65) with 20 RBI in 17 games since coming off the disabled list on June 18.

ATHLETICS 3, ASTROS 1: Yonder Alonso doubled and drove in two runs, and Rich Hill tied a season high with 10 strikeouts in six solid innings to give Oakland a win at Houston.

Hill (9-3) allowed three hits and one run to extend his winning streak to six games in his second start since coming off the disabled list on Saturday. Ryan Madson pitched a perfect ninth for his 17th save.

YANKEES 5, INDIANS 4: Didi Gregorius had two hits, including a solo homer, as the Yankees held on to beat the AL Central-leading Indians at Cleveland.