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 late 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 home stand many felt would determine their trade deadline fate.

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. After Austin Romine was unsuccessful in laying down a bunt, the catcher 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 get to, the ball rolling away for a double.

Chapman stopped it there, getting Denard Span to ground to short, Angel Pagan to line to second and striking out Brandon Belt on a full-count 103-mph fastball, to end it.

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 to 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 Yankees’ 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 faltered in the eighth.

Grant Green’s two-out, pinch-hit single put runners on the corners but Miller looked as if he’d get out of it, jumping ahead of pinch hitter Mac Williamson 0-and-2. But the right-handed hitter fought back to a ful -count, then lasered a fastball off the wall in left to tie it at 2.

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 over seven innings. He struck out six and walked three.

After Tanaka retired the Giants in order in a five-pitch top of the first, the Yankees gave him a lead in the bottom half.

Gardner led off by dumping a single to left and Starlin Castro, who had three hits to improve to 14-for-29 in his career vs. Bumgarner, followed by driving a 2-and-0 fastball into the gap in left-center for an RBI double.

The Yankees tacked on a run in the second. Ronald Torreyes, starting at short for the resting Didi Gregorius, flared a one-out single to left and, after Gardner flied out, went to third when Castro singled to left and leftfielder Angel Pagan booted the ball. With runners at the corners, Carlos Beltran, who reached base four times and made two standout defensive plays in leftfield, including throwing a runner out at the plate in the third, lined a 1-and-2 pitch to left to bring in Torreyes for a 2-0 lead.