NEW YORK -- Travis Hafner's 1,113th major-league game was his most efficient.
One at-bat. One pitch. One homer. One win.
Hafner's pinch-hit solo homer with two outs in the eighth inning Wednesday snapped a tie and lifted the New York Yankees to a come-from-behind 4-3 victory 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 David Hernandez into the right-field seats just to the right of the Yankees' bullpen.
"To sit for two and a half hours and then have to come out and get one at-bat, that's got to be tough to do," Yankees manager Joe Girardi said. "But it was a great at-bat."
It was the fourth career pinch-hit homer for Hafner, who clapped his hands as the ball sailed over the fence, and the earliest he has ever homered in a pinch-hitting appearance.
His earlier pinch-hit homers -- in 2006, 2008 and 2012 -- were hit in counts of 1-1 (twice) and 1-0.
"It's moments like these that are really special, that you remember," said Hafner, who signed with the Yankees last winter after 10 seasons with Cleveland.
The homer made a winner out of CC Sabathia, who saw Hafner homer 145 times during their five-plus seasons together in Cleveland from 2003 through 2008.
"In this ballpark, with his power, all it takes is the right pitch," said Sabathia, who recovered from allowing two runs during a laborious 31-pitch first inning to last eight innings. "He got that today."
Girardi said Hafner -- who is a .291 hitter in 55 pinch-hit at-bats -- might be better suited to pinch-hit duty because of his experience as a full-time designated hitter. Hafner hasn't played a game in the field since 2007, when he made 11 appearances at first base.
"I've pinch-hit quite a bit over the years," Hafner said. "You're not really cold. You're doing stuff the whole game, so you're ready to go when your number's called. For the most part, I enjoy pinch-hitting."
Hafner's blast completed 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.
The Yankees tied the game in the seventh by scoring three runs, all 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.
Brett Gardner, the lone Yankees player with two hits, greeted Tony Sipp with a two-run single to left to tie the game at 3-3.
"(Sipp's pitch) is up and out and over the plate, and give the guy some credit: He hit it where he should have," Diamondbacks manager Kirk Gibson said.
Sabathia improved to 3-1 by allowing three runs on six hits -- including just three after the first -- and one walk while striking out six. He retired 10 batters in a row between the first and fourth and finished his evening by setting down the final eight batters he faced.
"I think he just battled through it," Girardi said. "We've seen CC do that a number of times, where maybe he doesn't have his 'A' stuff and he finds a way to keep you in the game and doesn't give up big innings."
Mariano Rivera notched his fourth save of the season, and his record 612th overall, with a perfect ninth inning.
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.
"He did a really good job. Obviously, you want to try to get him the win, tack on some runs there," Goldschmidt said. "But he did a good job."
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 he 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 Pollock's sacrifice fly.
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 ballpark. ... Miley finished second in the National League Rookie of the Year balloting last year, the highest finish by a Diamondbacks player. Travis Lee (1998) and Brandon Webb (2003) each finished third.