NEW YORK -- Three outs from dropping into a tie for the American League East heading into the season's final day, the New York Yankees watched Raul Ibanez give them a crucial win with a game-tying homer and walk-off single.
Ibanez's two-run pinch-hit homer tied the game off Boston Red Sox reliever Andrew Bailey in the ninth and his two-out RBI single off Andrew Miller in the 12th won it 4-3 for the Yankees on Tuesday.
The crucial win on a rainy, misty night at Yankee Stadium maintained New York's one-game lead over the Baltimore Orioles in the American League East heading into the regular season's final day.
Ibanez's single off Miller (3-2) scored Francisco Cervelli, who walked in his first plate appearance of the season. Curtis Granderson, who singled to start the ninth-inning rally, also walked to extend the 12th.
Yankees reliever Derek Lowe (9-11) pitched two scoreless innings to get the win.
"We've been battling, this team, the resiliency and character in there, the fight ... it's a lot of fun," Ibanez said in an on-field interview on the stadium scoreboard.
The Orioles had already beaten the Tampa Bay Rays 1-0 to move within a half-game of the Yankees, who entered the ninth down 3-1.
But Granderson led off the inning with a single, and Ibanez drove a 1-2 pitch from Bailey over the wall in right to tie the game.
The Red Sox escaped more trouble, though, as reliever Mark Melancon came on with one out and the bases loaded to extend the game. Melancon got Mark Teixeira -- who had killed rallies all night -- to fly out to shallow center without scoring a run. He then got red-hot second baseman Robinson Cano to ground out to end the inning.
The lost opportunity could be especially costly Wednesday, as it resulted in the Yankees using closer Rafael Soriano for a second inning. Soriano threw 43 pitches, all but eliminating him from duty on the season's pivotal final day.
The Sox got the potential go-ahead run in scoring position off Lowe in the 11th, on a walk, fielder's choice and wild pitch. But Lowe struck out Ryan Lavarnway and intentionally walked Yankee-killer Pedro Ciriaco to bring up Jose Iglesias, who was hitting .109.
Iglesias hit a weak grounder to end the inning.
New York put the winning run on in the bottom of the 11th with a two-out single by Nick Swisher. But Alex Rodriguez's long drive to center was snared by center fielder Jacoby Ellsbury, who made a running, over-the-shoulder catch to end the inning.
The Red Sox, long removed from having much to play for, offered a lot more fight than they had in Monday's 10-2 loss.
Dustin Pedroia drove in a run with a double during a two-run first after sitting out with a fractured left ring finger Monday. Pedroia had reportedly been sent a text message by Orioles shortstop J.J. Hardy, asking him to play, and Baltimore had reportedly been upset with Boston's lineup full of players who spent most of the season in the minors on Monday, when the Yankees won 10-2.
The Yankees got a two-out single in the eighth by Russell Martin, but pinch runner Brett Gardner was then picked off by Craig Breslow to end the inning.
Boston first baseman James Loney then hit just his second home run in 29 games, off Soriano, to give the Sox a 3-1 lead in the ninth.
Rookie right-hander David Phelps gave the Yankees 5 1/3 innings of two-run ball, allowing three hits and striking out four.
Red Sox lefty Jon Lester, who had lost three in a row and allowed 10 runs in 20 innings, gave up eight hits in five innings, but constantly wiggled out of trouble.
The Yankees reached Lester for a run in the second on Eduardo Nunez's RBI single to make it 2-1. But Lester twice escaped jams with one out and runners on the corners by getting Teixeira to ground into inning-ending double plays. Lester also got Teixeira to ground out with two outs and two on in the fifth.
NOTES: Yankees right fielder Swisher moved back to the No. 2 spot in the order Tuesday after Ichiro Suzuki had been there in nine of the previous 10 games. Manager Joe Girardi said, with both players hot, he liked the switch-hitting Swisher up higher against the lefty. ... Top Yankees pitching prospect Manny Banuelos is scheduled to undergo Tommy John elbow ligament surgery, which likely would keep him from pitching next season. ... Right-hander Daisuke Matsuzaka will make what is likely to be his final start with the Red Sox in the season finale Wednesday. After winning 33 games in his first two seasons, the pending free agent has won just 17 the past four years, and he has gone 1-6 with a 7.68 ERA this season.