It began with starter David Phelps batting ahead of catcher Austin Romine and ended with Vernon Wells playing third base.

In between the Yankees eked out a 3-2 victory over the Rockies in front of 40,148 at Coors Field that falls into the bizarre category.

Not wanting three left-handed hitters in row if he had to hit for Phelps, manager Joe Girardi batted the pitcher eighth and Romine ninth.

Unable to use Eduardo Nunez, who has a rib cage injury, Girardi was forced to bring Wells in from left field in the ninth after the manager watched Travis Hafner whiff with the bases loaded while hitting for third baseman Chris Nelson.

“Playing third base with Mariano Rivera on the mound. That most likely is never going to happen again,’’ said Wells, who never played third base at any level but looked smooth fielding Carlos Gonzalez’s grounder in the ninth for the second out. “It was one of the cooler moments of my career.’’

There have been three games where Wells didn’t start because Girardi used left-handed hitters Brett Gardner, Brennan Boesch and Ichiro Suzuki in the outfield. One of those three days Girardi spotted Wells taking grounders at third and made a note if ever needed an emergency third baseman he would use Wells.

“Hopefully your instincts take over and hopefully you hit Lyle’s (Overbay) glove,’’ Wells said of the ninth-inning grounder.

Though Wells enjoyed the action at third, him coming out of a 3-for-23 slump with a three-hit game that included a two-run homer in the first inning and a leadoff single in the ninth played a much bigger part in the victory that stopped a two-game slide and improved the Yankees’ ledger to 19-13.

“It was a great win for our guys,’’ Girardi said. “They hung in there and made plays.’’

Strong pitching from Phelps, Preston Claiborne and David Robertson limited the Rockies to two runs across eight innings. The only runs were on Todd Helton’s two-run homer in the second.

Wells opened the ninth with an infield single and stole second in front of Overbay walking. Suzuki advanced the runners with a bunt and with the count 3-0 on Jayson Nix and the infield in, Rafael Bentancourt issued the fourth ball intentionally.

Hafner fanned and Boesch barely beat out a smash to third baseman Nolan Arenado, who made a diving stop on as Wells scored.

“I think, but your guess is as good as mine,’’ Boesch said when asked if he was safe.