NEW YORK -- Pinch-hitter Travis Hafner hit a solo homer with two outs in the eighth inning Wednesday to snap a tie and lift the New York Yankees to a come-from-behind 4-3 win over the Arizona Diamondbacks in front of 34,369 at Yankee Stadium.
Hafner, who was pinch-hitting for Ben Francisco, laced the first pitch he saw from losing pitcher David Hernandez into the right-field seats just to the right of the Yankees' bullpen. It was the fourth career pinch-hit homer for Hafner, who clapped his hands as the ball sailed over the fence.
The homer capped a four-run comeback over the final two innings by the Yankees, who trailed 3-0 and had just two hits against Arizona's Wade Miley through six innings.
Hafner's blast made a winner out of CC Sabathia (3-1), who recovered from a laborious first inning to throw eight strong frames. Sabathia allowed three runs on six hits and one walk while striking out six.
Mariano Rivera recorded his fourth save of the season, and his record 612th overall, with a perfect ninth inning.
Brett Gardner had two hits for the Yankees, including the game-tying two-run single in the seventh.
The Yankees scored all three of their runs in the seventh with two outs. Brennan Boesch's double sent Francisco, who had singled with one out, to third. Consecutive walks to Eduardo Nunez and Jayson Nix -- the second of which brought Francisco home -- chased Miley. Gardner greeted Tony Sipp with a two-run single to left to tie the game at 3-3.
Paul Goldschmidt hit a two-run homer in the first for the Diamondbacks while Cody Ross had a pair of singles.
Miley allowed three runs, all earned, on four hits and three walks while striking out three in 6 2/3 innings.
Sabathia was dominant after the first inning. He allowed just three hits the rest of the way and retired 10 batters in a row between the first and fourth and finished his evening by setting down the final eight batters he faced.
The Diamondbacks took a quick 2-0 lead off a scuffling Sabathia, who allowed a leadoff bloop double to A.J. Pollock before Goldschmidt launched a deep homer to right one out later.
Sabathia walked Miguel Montero and allowed a single to Ross, but settled down and struck out Alfredo Marte and retired Gerardo Parra on a fly to right.
Arizona extended the lead to 3-0 when Josh Wilson tripled leading off the fifth and came home on Pollack's sacrifice fly.
Miley was impressive and efficient after being staked to the early lead. He surrendered just one hit -- a single leading off the first by Gardner -- and didn't allow a runner past second through the first five innings, a stretch in which he threw just 63 pitches.
NOTES: Yankees second baseman Robinson Cano and first baseman Mark Teixeira received their 2012 Gold Gloves during a pregame ceremony. ... Teixeira swung a bat in a swimming pool on Tuesday and took 20 dry swings from both sides of the plate Wednesday. Teixeira, who suffered a strained right wrist during workouts with Team USA prior to the World Baseball Classic in early March, is still expected to be out until at least early May. ... Yankees left-hander Andy Pettitte, who had his start pushed back twice due to back spasms, remains in line to start Friday in Toronto against the Blue Jays. ... This week's trip to the new Yankee Stadium is the first for the Diamondbacks, who have now played in every current Major League Baseball ballpark. ... Miley finished second in the National League Rookie of the Year balloting last year, the highest finish ever by a Diamondbacks player. Travis Lee (1998) and Brandon Webb (2003) each finished third.