David Wright slides in with the game-winning run. Photo: Charles Wenzelberg/New York Post

SLIDES & LOWS: David Wright slides in with the game-winning run as Mariano Rivera, who failed to record an out in a save situation for the first time in his career, walks off the mound. (Charles Wenzelberg/New York Post)

Mariano Rivera threw the first pitch at Citi Field and the last, but who could have anticipated a Mets celebration near second base as the finishing touch to the ninth inning last night?

But there was Rivera walking dejectedly from the mound, after failing to retire a batter in a save situation for the first time in his career. Lucas Duda’s bat had shattered into “50 pieces” and the party was on for the Mets with a 2-1 victory over the Yankees before 31,877 — an all-time Subway Series low — at Citi Field.

“[Rivera] is the best closer ever, so I’m just happy about the win,” Duda said after his single scored David Wright with the winning run. “I wouldn’t say a good swing, but just enough.”

Rivera, who threw out the ceremonial first pitch as he was honored before his last appearance against the Mets at Citi Field, allowed a bloop double to Daniel Murphy leading off the ninth before Wright tied the game with a single and took second on Brett Gardner’s error on a throw to the plate. Duda followed with the game-winner, allowing the Mets (20-29) to win a third straight game in their final at-bat. The Mets hadn’t won three straight games since April 6-8.

“It was a great game until I got into the game,” said Rivera, whose blown save was the third of his career against the Mets.

The Yankees (30-21) have their first three-game losing streak of the season. The Subway Series will resume tonight in The Bronx, with Jeremy Hefner facing David Phelps.

“This series to us is huge,” said manager Terry Collins, who was ejected for arguing a call in the sixth inning. “This is a team that is struggling against a team that is playing great. To have two wins against them is huge for us.”

Matt Harvey’s indoctrination into the Subway Series was a smashing success. The stud right-hander received a no-decision after allowing one run on six hits over eight innings with 10 strikeouts and no walks.

Hiroki Kuroda fired seven shutout innings for the Yankees, allowing four hits and striking out seven with no walks. The right-hander showed no effects of the bruised right calf he sustained last week after getting hit with a batted ball in Baltimore.

Brett Gardner’s defensive heroics prevented the Mets from tying the game in the sixth. Murphy hit a shot to the gap in left center that Gardner caught crashing into the fence, forcing Ruben Tejada to retreat to first base. A night earlier, Gardner went above the fence in left-center to rob Murphy of a two-run homer.

“If we keep winning games, [Gardner] could steal one from me every six innings, that would be fine,” Murphy said.

After Gardner’s catch last night, the Mets still had a chance to tie the game in the sixth, but Tejada was picked off second base by Kuroda to end the inning. Second-base ump Adrian Johnson originally ruled Tejada safe, but changed his call, bringing a protest by Collins, who was ejected for the second time in eight days.

Collins got exactly what he expected from the 24-year-old Harvey, who seemed unfazed facing the team he rooted for growing up in southeast Connecticut.

“Whatever I could do to go out and help the team was what was on my mind,” Harvey said. “Not who we would be facing or whatever.”

Lyle Overbay’s RBI single in the sixth put the Mets in a 1-0 hole, after Marlon Byrd mishandled Gardner’s leadoff single, putting the Yankees’ leadoff hitter on second. Harvey was officially charged with an earned run because of a Robinson Cano grounder to first — in official scorer Howie Karpin’s estimation Gardner would have advanced to second on the play had Byrd not committed the error — and scored on Overbay’s single.

Ike Davis, shifted to No. 8 in the batting order, finished 0-for-3 with two strikeouts. The struggling first baseman has struck out five times in the first two Subway Series games.

Tejada’s throwing error in the fifth allowed Ichiro Suzuki to reach first leading off the inning before Harvey retired the next three batters to keep the game scoreless.

Harvey had to work through the third, after allowing a leadoff single to Reid Brignac. Chris Stewart and Kuroda then whiffed in succession before Gardner singled. Harvey then struck out Cano on a 90-mph slider to end the inning.

The Mets’ best shot against Kuroda early came in the first, when Murphy and Wright singled consecutively with one out before Duda and Byrd were retired.