NEW YORK — With midnight approaching, the Baltimore Orioles’ bats awoke for one more improbable rally.
Now they have a last shot to finally overtake the New York Yankees.
J.J. Hardy hit an RBI double in the 13th inning and Baltimore bounced back from a demoralizing loss to outlast the Yankees, 2-1, Thursday night, forcing a deciding Game 5 in the American League Division Series.
After splitting 22 games this year, it all comes down this: a game for a spot in the AL Championship Series.
Game 1 winner CC Sabathia was set to pitch the deciding game for the Yankees against Jason Hammel of the Orioles.
‘‘It’s the same game whether it’s the first game of the season or the postseason,’’ said Derek Jeter, who shifted to designated hitter because of a sore left foot. ‘‘We’re going to try to have fun with it, enjoy it.’’
The Orioles were 0 for 8 with runners in scoring position until Hardy doubled off David Phelps with one out to score Manny Machado.
Phelps had relieved in the 12th after Joba Chamberlain was hit by a flying broken bat, forcing him to leave with a bruised right elbow.
Orioles closer Jim Johnson bounced back from allowing Raul Ibanez’s pinch-hit homer in the ninth inning Wednesday to earn his second save in the series with a perfect 13th.
Hours after learning Joe Girardi had kept quiet that his father died last Saturday, the Yankees couldn’t rally late. This time, Girardi called upon Eric Chavez to hit for slumping Alex Rodriguez, but he lined out to third base to end it.
‘‘It’s obviously frustrating,’’ Rodriguez said. ‘‘That was a situation that I could do some damage, and just couldn’t get it done tonight.’’
Baltimore’s win pushed all four Division Series to five games for the first time since the round began in 1995.
After dropping Game 1, the Orioles rebounded with another one-run win in a season in which they had the best record in the majors in such games at 29-9. But they lost in stunning fashion in 12 innings Wednesday night, when Ibanez homered twice in his two at-bats after hitting for Rodriguez.
Nate McLouth homered off Phil Hughes to start the fifth, but Baltimore wasted three shots with a runner on third base in the first four innings.
Matt Wieters knocked Chamberlain out of the game with a broken-bat single to lead off the 12th inning that struck Chamberlain’s surgically repaired right elbow. Fans sat silent as Chamberlain bent over in pain. He was checked out by trainer Steve Donahue and Girardi. Chamberlain tested the elbow with three pitches before walking off the field. X-rays were negative.
Many of the Orioles gathered near their bat rack in the dugout for an impromptu cheer before the 13th, and Machado then led off with a double. One out later, Hardy hit a one-bouncer off the wall in left field for his first RBI of the series.
Facing elimination for the second time this postseason, Orioles manager Buck Showalter turned to Joe Saunders, who pitched 5⅔ innings of one-run ball in the wild-card win over Texas.
He was just as crafty against New York, engaging with Hughes in a duel of who could get out of the tougher jam. The Yankees put a runner on in every inning against Saunders but failed to scored until the sixth.
Jeter lined an outside pitch to right field for a leadoff double in sixth, showing no ill effects of a bruised left foot that kept him from playing shortstop in the postseason for the first time in his career.
He advanced on Ichiro Suzuki’s sacrifice and scored on Robinson Cano’s grounder to second. Showalter then lifted Saunders for righthander Tommy Hunter to face Rodriguez. Rodriguez struck out to loud boos and tossed his bat.