NEW YORK (AP) - Tomas Nido hit a tying double with two outs in the 10th inning and scored the winning run on a throwing error by reliever Tanner Scott, and the New York Mets rallied to beat the Miami Marlins 5-4 on Saturday after honoring Keith Hernandez.
Pete Alonso homered and Francisco Lindor lined a two-run shot for the NL East leaders, who overcame injuries to right fielder Starling Marte and catcher James McCann in the middle innings.
Both exited the game and are headed for MRIs on Sunday.
Miami designated hitter Garrett Cooper and manager Don Mattingly were ejected for jawing in the seventh with plate umpire Mark Ripperger.
After a pregame ceremony to retire No. 17 in honor of Hernandez, the Mets pulled out a back-and-forth game in front of a sellout crowd of 43,336. New York got its fourth walk-off win and improved to 7-0 in extra innings.
Jesus Aguilar hit a tying homer in the eighth inning for Miami, and pinch-runner Billy Hamilton scored on Lindor's throwing error at shortstop in the 10th to give the Marlins a 4-3 lead.
Scott (4-3) struck out the first two batters in the bottom half before Nido, who replaced McCann behind the plate, hit a grounder down the third base line. The ball got under Brian Anderson's glove and rolled into left field, allowing automatic runner Mark Canha to score from second base.
Brandon Nimmo then hit a comebacker to Scott, who fumbled the ball twice before picking it up off the mound and rushing a low, wild throw past first.
Nido scored easily and the excited Mets swarmed Nimmo near second base.
Colin Holderman (4-0) worked one inning for the win. After the Marlins scored in the 10th, Jon Berti got picked off second base by Nido, costing them a good chance to add more.
Anderson had an RBI double for Miami in the sixth, but Mets second baseman Luis Guillorme made an incredible, twisting relay throw to the plate to cut down another runner on the play. McCann got hurt making a swipe tag.
Miami went ahead 2-1 on a wild pitch by reliever Seth Lugo, but Lindor put the Mets up 3-2 with a two-run homer in the bottom half that chased rookie starter Braxton Garrett.
Alonso hit a solo shot in the fourth for New York's first hit of the day and his 70th RBI of the season.
Aguilar also doubled, singled and scored twice for the Marlins, who had won seven of nine.
Mets starter Carlos Carrasco pitched out of trouble, allowing two runs and seven hits in 5 2/3 innings.
Mets: Marte was removed in the fourth with left groin tightness. ... McCann exited in the sixth with discomfort on his left side. ... 2B/OF Jeff McNeil was out of the starting lineup for rest. He is expected to play Sunday and then go on paternity leave, meaning he'll likely miss some or all of the three-game series at second-place Atlanta that begins Monday night. McNeil flied out as a pinch-hitter in the eighth and stayed in to play right field. ... RHP Jacob deGrom (stress reaction in right scapula) is scheduled to pitch into the fourth inning during his third minor league rehab start in the middle of the upcoming week.
Marlins: A few hours before he's likely to be picked for the NL All-Star team, RHP Sandy Alcantara (9-3, 1.82 ERA) pitches the finale of the four-game series Sunday. Alcantara is a top contender to start for the National League on July 19 at Dodger Stadium. He struck out 10 in eight shutout innings of two-hit ball Tuesday against the Angels.
"Sandy's been huge," Mattingly said. "Basically every day he pitches, your 'pen gets a day off. ... He's just been a leader for our club. I had the same thing in LA with (Clayton) Kershaw. Felt like every time he pitched you were going to win."
Mets: RHP Taijuan Walker (7-2, 2.86), also a potential All-Star candidate, has won four consecutive decisions.
More AP MLB: https://apnews.com/hub/mlb and https://twitter.com/AP_Sports