MLB

Yankees rally past Diamondbacks on Hafner pinch-hit homer

NOT ‘HAF’ BAD: Travis Hafner blasts a go-ahead, solo home run in the eighth inning last night, earning a high-five from third-base coach Rob Thomson (inset), which proved to be the game-winner in a 4-3 victory over the Diamondbacks in The Bronx. (Paul J. Bereswill)

The loud sound that filled a half-empty Yankee Stadium immediately let those who remained know the home team was going to present Mariano Rivera with a one-run lead to work the final inning.

There was no need to follow the flight of Travis Hafner’s solo homer, because the sound was loud enough and solid enough to know that with Hafner’s strength and the cozy Yankee Stadium right field the ball was easily going to clear the wall.

“Moments like this are really special, and you remember them for a long time,’’ Hafner said of his game-winning homer off Arizona’s David Hernandez that carried the Yankees to a 4-3 come-from-behind victory in front of an announced crowd of 34,369.

Hafner, who didn’t start the game against lefty Wade Miley, went to the plate with two outs and the score tied, 3-3. One pitch was all he needed to put the Yankees three outs from a victory that Rivera saved with a perfect ninth inning.

“I saw him throw Robbie [Cano] three or four breaking balls,’’ Hafner said of Hernandez, who watched Cano line out opening the frame. “I was only looking for a good pitch to hit, but he throws 95 to 96 mph so have to be ready for that.’’

Hernandez opted for a fastball and paid the price.

“I was excited,’’ CC Sabathia said of watching Hafner walk to the plate as the hitter for Ben Francisco. “In this ballpark with his power …’’

Rivera recorded his fourth save of the season and upped the all-time saves record to 612.

The win, which hiked Sabathia’s record to 3-1, was the 8-5 Yankees’ third straight and seventh in eight games.

For six innings it looked like the three runs Sabathia gave up were going to get him beat because Miley allowed two hits and faced only one Yankee with a runner in scoring position.

“You always want to keep it as close as possible,’’ said Sabathia, who gave up a two-run homer to Paul Goldschmidt in the first and a solo run in the fifth. “Give these guys a chance to swing the bat.’’

Working with a fastball that never topped 90 mph, Sabathia said he survived on “smoke and mirrors’’ and “didn’t have anything out there.’’

Still, in eight innings he allowed three runs, six hits, a walk and whiffed six and has won three straight.

“There is a lot you can learn watching the way he goes about his business,’’ manager Joe Girardi said of his ace with the fading velocity and who had a bone spur removed from the left elbow last October. “He might not hit 96 or 98, but he is the same guy with command and two off-speed pitches. The bottom line he has to hit spots.’’

Without a break-through seventh inning against Miley, a 16-game winner last year when he was an All-Star and finished second to Bryce Harper in the NL Rookie of the Year race, Hafner isn’t the hero in the eighth.

A bases-loaded, two-out walk to Jayson Nix, the No. 9 hitter, forced in the Yankees’ first run and Brett Gardner followed by slicing a 2-2 pitch to left that plated two and tied the score, 3-3.

That set it up for Girardi to hit Hafner for Francisco.

“Haf has the ability to make ballparks look small,’’ Girardi said of his DH, who has four homers. “It doesn’t matter what ballpark it is.’’

george.king@nypost.com