Hal Steinbrenner doesn’t see his club play all that many games in person.

Friday night was one of those, and the Yankees put a significant foot forward in trying to convince the managing general partner to hold off on giving general manager Brian Cashman the go-ahead for a trade deadline selloff.

It was not without plenty of drama.

Masahiro Tanaka pitched a gem but the normally impenetrable back end of the bullpen coughed up a two-run lead.

The Yankees recovered, however, pushing across a run in the eighth to beat the slumping, error-prone Giants, 3-2, in front of 45,304 on a steamy night at the Stadium.

The Yankees (49-47) improved to 5-3 on a 10-game homestand many believe will determine their trade deadline fate.

advertisement | advertise on newsday

“Right now we feel like we’re playing better baseball,” said Carlos Beltran, who went 2-for-2 with an RBI, reached base four times and made two standout defensive plays in rightfield, including throwing out a runner at home in the third inning to keep it a 2-0 game. “We need to continue to win games and see what happens.”

After Andrew Miller gave up a two-out, RBI double in the top of the eighth that tied it at 2, Chase Headley started the bottom half against lefty Josh Osich with an infield single. Mark Teixeira, a defensive replacement for Rob Refsnyder in the seventh, walked. Austin Romine, first unsuccessful in laying down a bunt, bounced one to short, where Brandon Crawford stepped on second, then threw wildly to first. The shortstop’s third error of the night, and fourth by the Giants, allowed Headley to score to make it 3-2.

Aroldis Chapman walked a tightrope in the ninth, but still emerged with his 20th save in 21 chances. Gregor Blanco led off with a slicer to left that a sliding Brett Gardner couldn’t catch, the ball glancing off his glove and rolling away.

But Chapman retired three straight, ending it with a strikeout of Brandon Belt on a 103-mph fastball.

“It’s part of the game,” Chapman said through his translator of the unlucky start to the ninth. “You have to keep going.”

Yankees videos

Pitching on regular four days’ rest — you might have read Tanaka had struggled somewhat with that this season — the righthander pitched six shutout innings. Tanaka, who brought a 1.05 ERA into the night when pitching on an extra day’s rest compared with a 5.33 ERA when pitching on regular rest, limited the NL West-leading Giants (57-39), who have lost six straight, to four hits. He stranded six and held the Giants to 0-for-6 with runners in scoring position, departing with a 2-0 lead.

But a bullpen that came into the game having not allowed a run in 31 consecutive innings saw that streak come to an end.

First, Dellin Betances allowed a run in the seventh — the righthander allowed a hit and a walk and threw a wild pitch that made it 2-1 — and Miller (6-1), who nevertheless got the victory, faltered in the eighth.

With runners on the corners and two outs, pinch hitter Mac Williamson fought back from an 0-and-2 hole to a full-count before lasering a fastball off the wall in left to tie it at 2. Miller said the way Gardner played the ball off the wall, which kept a second run from crossing, “won the game.”

Madison Bumgarner, pitching for the first time since July 15, when he allowed four runs, came out rusty and the Yankees took advantage, scoring one run in each of the first two innings. The lefthander allowed two runs and seven hits in seven innings, with three of the hits belonging to Starlin Castro, who improved to 14-for-30 in his career vs. Bumgarner.

advertisement | advertise on newsday

“These are tough losses if you lose games like this,” Girardi said. “Especially when you have the lead and you weren’t able to hold it and you use your guys [Betances, Miller and Chapman]. But that’s not the case and I don’t have to worry about it.”