Updated

Bobby Valentine never expected his first season — and perhaps only — with Boston to end in last place.

Raul Ibanez tied it with a pinch-hit homer in the ninth inning, then had an RBI single in the 12th, helping the Yankees remain a game up on Baltimore in the AL East with one game to go by beating the Red Sox 4-3 on Tuesday night.

With their season high-tying seventh straight loss, the Red Sox dropped to 69-92, ensuring they will finish in last place for the first time since 1992.

"We didn't start the season to finish fifth . . . or fourth, or third, or second . . .," Valentine said.

Valentine signed a two-year deal to manage Boston after its September collapse last season cost Terry Francona his job. But the Red Sox were beset by injuries and underperformance this year. They fell to 16-41 since Aug. 1, and many are calling for Valentine to be fired.

Boston took a 3-1 lead into the ninth Tuesday, but closer Andrew Bailey, who missed much of the season after having surgery, gave up a two-run homer to Ibanez in the ninth to tie it.

Ibanez then had an RBI single off Andrew Miller (3-2) in the 12th to give New York a win to stay atop the division. The Yankees need a win or Orioles loss on the final day of the season to secure their 13th division title since 1996. The Orioles beat Tampa Bay 1-0 earlier.

If the teams end up even after Wednesday's games, they'll play a tiebreaker Thursday in Baltimore.

The Yankees kept missing chances on a misty night. They were 0-58 when trailing after eight innings this season before rallying in the ninth.

Curtis Granderson led off with a single off closer Andrew Bailey and Ibanez lined a shot to right field to make it 3-all.

I'll have a long offseason," Bailey said. "I've let the team down a couple of times."

Ibanez came up again with two outs in the 12th after Francisco Cervelli walked in his first plate appearance of the year and Granderson drew a walk from Miller.

Ibanez hit a grounder out of the reach of shortstop Jose Iglesias and Cervelli flopped into home plate. The Yankees ran out to first base to mob Ibanez, who had a tying two-run homer against Oakland in the 13th inning on Sept. 22. He was doused with a bucket of water during a postgame interview.

"We stuck together. We stayed after them, and we were able to pull it out," Ibanez said. "I was trying not to do too much, and it found a hole."

Derek Lowe (9-11) pitched two innings for the win.

While the Orioles were chasing the Yankees in the standings, Lowe's outing was delayed briefly in the 12th by another kind of bird. A member of the grounds crew, using a bucket, chased a bird that landed on the infield and was reluctant to fly off.

The Yankees had at least one hit in each of the first six innings before the top three in the batting order went out successively in the seventh against Junichi Tazawa.

They loaded the bases against Bailey in the ninth but Mark Melancon relieved and got Mark Teixeira to pop up to an outfield playing in and Robinson Cano to ground out.

Managing as if this were a playoff game, manager Joe Girardi used much of his well-rested bullpen. He called on Rafael Soriano for the ninth, trailing 2-1, and the closer gave up a leadoff homer to James Loney, rankling many of the 41,564 who stayed through the rain.

He also pitched the 10th, walking one batter. It was the first time this season Soriano pitched more than 1 1-3 innings. He threw 43 pitches, his most since Sept. 25, 2005.

"Hopefully, he feels OK tomorrow if I need him," Girardi said. "I've said it all along and I'll say it again: trying to win the division."

Jacoby Ellsbury and Dustin Pedroia were back in Boston's lineup a day after sitting out of a 10-2 loss and immediately made an impact. Ellsbury, who sat against left-hander CC Sabathia, singled and scored from first on a double to right-center by Pedroia, playing with a broken left ring finger. Cody Ross added a sacrifice fly against David Phelps for a 2-0 lead.

Valentine said that he fell off his bicycle when he read the text from his staff saying that Pedroia was able to play. The second baseman went 2 for 5.

"He had great at-bats all night. He's an amazing character," Valentine said.

Eduardo Nunez had an RBI single off Jon Lester after Granderson reached on an infield hit, advanced to second on a throwing error by third baseman Pedro Ciriaco on the play and then stole third base.

NOTES: Boston entered the game 24 games out of first place. The previous time they were that far out was after games of Sept. 22, 1969. ... Boston's Daisuke Matsuzaka (1-6) faces New York's Hiroki Kuroda (15-11) in the regular-season finale.