This story is from BostonGlobe.com, the only place for complete digital access to the Globe.
NEW YORK — The Red Sox were poised to inflict some delicious pain on their old rivals Tuesday night. They were three outs away from dropping the Yankees into a tie for the American League East with the Orioles with one game to play.
It was a scenario New York desperately wanted to avoid. A tie for the division title would require a one-game playoff Thursday in Baltimore. The loser then would play in the one-game wild-card playoff Friday.
But those three outs never came. Raul Ibanez tied the game with a two-run pinch-hit homer in the bottom of the ninth inning then won it with a single in the 12th as the Yankees beat the Red Sox, 4-3.
“I thought it was in the cards there. But obviously it doesn’t matter what I think,” said Bobby Valentine, whose final days as manager have become painful for all involved.
Valentine hasn’t been fired yet. But at 69-92, the Red Sox are guaranteed of finishing last for the first time since 1992. They have lost seven straight games, matching a season high, and 11 of 12.
It is almost impossible to imagine the Red Sox moving forward with Valentine still in the dugout. They are a team that rarely plays with passion and on Tuesday there was little sense of purpose late in the game.
Lefthander Andrew Miller got two quick outs in the 12th inning then got ahead of Francisco Cervelli 0 and 2.
A third-string catcher, Cervelli had not batted in a major league game since Sept. 8, 2011. But Miller threw him four straight balls to keep the inning alive
“I thought I made some good pitches for him to chase,” Miller said. “He didn’t.”
Miller (3-2) was asked why he didn’t just go after Cervelli instead of working the corners.
“I missed with a 2-2 pitch and the 3-2 pitch was pretty darn close,” Miller said.
Curtis Granderson, a .216 hitter against lefthanders, then walked on four pitches. None were close. Ibanez was next and he slipped a groundball through the hole at shortstop to win the game.
It was the eighth walkoff loss of the season for the Sox, who are 2-10 in extra innings. They also fell to 5-12 against the Yankees, their most losses against New York since 2001.
The Yankees now need only to beat the Red Sox and Daisuke Matsuzaka Wednesday night to win the division.
Sox closer Andrew Bailey inherited a 3-1 lead in the ninth thanks to a home run by James Loney in the top of the inning off Rafael Soriano.
Granderson led off with a single to right field before Ibanez lined a home run just over the wall in right field.
Bailey, who has blown three saves in nine chances, allowed a double by Derek Jeter with one out. The Red Sox then intentionally walked Nick Swisher to get to Alex Rodriguez. He also walked.
“I let the team down,” Bailey said. “What happened these last two weeks is only going to keep me motivated.”
With the bases loaded, Valentine took out Bailey and called in righthander Mark Melancon.
It worked. Melancon, a former Yankees prospect, got Mark Teixeira to pop to shallow center field. Robinson Cano was next and the hottest hitter in the Yankees lineup grounded to second.
Then came a bunch of zeros on the scoreboard. Melancon pitched a scoreless inning as did Vicente Padilla, who was saved when Jacoby Ellsbury made a terrific running catch on a ball rifled to center by Rodriguez to end the 11th inning.
The Yankees got two innings out of Soriano and two more from Derek Lowe (9-11).
A day after Valentine fielded a lineup of primarily Triple A players, the Red Sox used the varsity against the Yankees.
Ellsbury was back in center field after another day off. Dustin Pedroia shook off a broken left ring finger and started at second base.
That combination paid off immediately against Yankees starter David Phelps.
Ellsbury dropped a leadoff single into center field and scored when Pedroia ripped a 2-and-2 fastball into the gap in right field for a double.
Daniel Nava grounded to first base, allowing Pedroia to take second. Cody Ross then drove in his 80th run with a sacrifice fly to center field.
Red Sox starter Jon Lester lasted five innings, giving up one run on eight hits. He walked one and struck out one.
The lefthander left the game because of back soreness that started while he was warming up. Lester ended his season with a 4.82 earned run average, the worst of his seven-year career.
Rich Hill, Junichi Tazawa, and Craig Breslow got the lead to Bailey.
“We finished fifth. It’s not good enough,” Lester said. “It’s been a long year for a lot of people for a lot of different reasons. I’m glad it’s over and we move on. Over for me.
“Going to a much-needed offseason, regroup, and come back to spring training next year ready to kick some people’s asses.”