Aaron Boone went to the mound with two outs in the top of the sixth with James Paxton pitching as well as the Yankees could have hoped.

The manager normally visits pitchers only to take them out. This time, after a brief chat with Paxton, Boone left him in to finish the inning.

“He gave me the chance to compete and keep on going,’’ Paxton said after the Yankees’ 4-1 win over the Astros in Game 5 of the ALCS at Yankee Stadium on Friday. “I wanted it. And I did everything I could.”

After having struck out Robinson Chirinos twice, Paxton saw the catcher turn on a pitch to deep left field. It seemed like it might get to the seats to draw the Astros to within a run, but came up just short, as Brett Gardner made the catch to end the inning — and Paxton’s night after a season-high 112 pitches.

“When that ball went up, I was begging it to stay in and it did,” Paxton said. “I just got fired up. It was awesome.”

It ended an outing in which Paxton went toe-to-toe with Justin Verlander and outdid the right-hander.

Despite another shaky first inning in which he misplayed a comebacker into a single, issued a walk and allowed a run to score on a wild pitch, Paxton recovered and had a terrific outing that allowed the Yankees to avoid elimination.

It was a far better showing than Paxton had in his first two postseason starts, when he allowed three runs to the Twins in the ALDS and then was knocked out in the third inning of his start against the Astros in the ALCS.

Paxton got through the top of the Astros’ batting order in the fifth and with the Yankees desperate for length from their starters, Boone kept him out there for the sixth — and it paid off.

He walked Correa with one out in the sixth and then struck out Yordan Alvarez for the second out.

That’s when Boone made the unusual trip to the mound.

“Frankly, I was up in the air walking out there,’’ Boone said. “I liked the matchup and how he was attacking Chirinos. The last thing I wanted him to do was throw it down in a heater, which was a mistake that almost got him. I felt like I just wanted to get a look at Gary [Sanchez] and at [Paxton] to see and have a feel if he had a little bit left, because obviously we were pushing him pretty far right there.’’

Paxton allowed just the one run over six innings, allowing four hits and four walks — while striking out nine.

“This is definitely the biggest game in my career,’’ Paxton said. “The first two postseason games definitely helped prepare me for this. This was even more so intensity-wise.’’