DETROIT (AP) Manager Joe Girardi wanted to give Didi Gregorius a night off Thursday against the Detroit Tigers.
Luckily for the New York Yankees, the shortstop was ready to go for the last two innings.
Gregorius's perfect relay retired Justin Upton at the plate to end the eighth, and he started a slick double play in the ninth as the Yankees held off the Tigers 5-4.
''I wanted to give him a day, because we had an extra game and he's playing so hard every night,'' Girardi said. ''I knew we'd have him back out there tomorrow, but it turned out that we needed him tonight. He saved the game with those two defensive plays - no doubt about it.''
After scoring against relievers Dellin Betances and Andrew Miller, Detroit was down 5-3 going into the ninth. The Tigers quickly loaded the bases against Aroldis Chapman on a single, a walk and a bunt single.
Gregorius then scampered up the middle to field a hard grounder by J.D. Martinez and made a glove flip to second baseman Starlin Castro, who caught the ball with his bare hand and let go a strong, off-balance relay. A run scored on the play, with the potential tying run moving to third.
The Yankees chose to pitch to Tigers star Miguel Cabrera, and Chapman retired him on a routine grounder for his eighth save.
''We get that great double play, and then we've got Miggy coming up with Victor (Martinez) on deck,'' Girardi said. ''That's not much fun, no matter how you want to face it. Luckily, we got the out to end the game.''
Jacoby Ellsbury drove in three runs and Rob Refsnyder had two key hits for the Yankees in a makeup game from a rainout on April 10. New York had lost three straight.
The Tigers have lost five of six.
''We've had a few games in the last few days where we fight back, but I'm getting tired of fighting back,'' Tigers manager Brad Ausmus said. ''I'd like to hold on to a lead one time.''
Matt Boyd (0-1) took a no-hit bid into the sixth. He allowed four runs on six hits and a walk in 6 1/3 innings.
''We were looking at his pitch count and hoping that he could get through eight, but they started finding holes and lofting singles into the outfield,'' Ausmus said. ''Five feet in either direction, and a couple of those are fine, but that's baseball.''
Boyd said he thought the Yankees were faster to make adjustments than he was.
''I got them out with good pitches the first couple times, but they started hitting those same pitches as I got deeper into the game,'' he said. ''You have to do something different, and I wasn't quick enough.''
Betances (2-2) wound up with the win.
Michael Pineda, perhaps pitching for his spot in the Yankees' rotation, threw well into the sixth. He gave up one run on seven hits in 5 2-3 innings, striking out eight and walking none.
''This was a very important game for me,'' he said. ''I still had my confidence, but it has been hard to not help the team win. Today, though, I made adjustments and I was able to keep the ball down.''
Mike Aviles hit an RBI double off Betances that made it 5-2.
Pinch hitter Ian Kinsler hit an RBI double in the eighth against Miller. Justin Upton was thrown out at the plate on the play, with Gregorius taking a relay from left fielder Brett Gardner.
Ausmus challenged the play, saying that catcher Austin Romine had blocked the plate, but the call was quickly upheld.
''We knew it was a reach, but we had nothing to lose,'' he said.
Refsnyder hit a tiebreaking single in the seventh for a 2-1 lead.
The Tigers optioned LHP Kyle Ryan to Triple-A Toledo after the game, and will recall LHP Blaine Hardy before Friday's game.
Yankees: RHP Luis Severino is scheduled to start for Triple-A Scranton/Wilkes-Barre on Friday. Severino strained his right triceps on May 13, and was activated from the disabled list on Monday and optioned to the RailRiders.
Tigers: Kinsler was out of the starting lineup for the third time in nine games on Thursday, but Ausmus said it wasn't related to the illness that caused him to miss the previous two games.
Thursday marked the first time that Maybin, Miller and Cabrera had appeared in the same game. In 2007, Maybin and Miller were the key players sent to Miami in the trade that brought Cabrera to the Tigers.
Yankees: New York travels to Baltimore to start a three-game weekend series. Nathan Eovaldi (6-2, 3.71) faces Chris Tillman (7-1, 2.92) in the opener. Eovaldi is 6-0 in his last seven starts, including five straight wins.
Tigers: Host the White Sox on Friday in the opener of a three-game series. Jordan Zimmermann (7-2, 2.52) is scheduled to pitch for the Tigers after missing his last start with a groin strain. Carlos Rondon (2-4, 4.24) pitches for the White Sox, who will be bringing Alex Avila back for his first game against the Tigers.