BOSTON (AP) — The Baltimore Orioles did plenty to hurt their chances despite Chris Davis' team-record 51st homer.
The best fielding team in the majors committed three errors, Scott Feldman walked a season-high six batters and they had to face Boston closer Koji Uehara, who had retired his previous 37 hitters.
But Danny Valencia ended that streak with a triple to lead off the ninth, Matt Wieters' hit a go-ahead sacrifice fly and the Orioles beat the Red Sox 3-2 on Tuesday night to stay two games behind in the AL wild-card race.
"They were real frustrated that we didn't make a couple of plays that we normally made," Baltimore manager Buck Showalter said, "but the bullpen was really good. Scotty bent but didn't break.
"You don't like your chances there with Koji, but we got a big hit from Danny."
Despite the loss, Boston's magic number to clinch the AL East dropped to three when Tampa Bay lost to Texas 7-1.
The Orioles overcame a 2-0 deficit on Brian Roberts' run-scoring groundout in the fifth and Davis' homer in the sixth that tied the score 2-2 and broke the club record set by Brady Anderson in 1996.
"I'm excited," Davis said. "I've said it all along. When you're hitting homers and your team's not winning it feels like it's kind of for nothing. So I was obviously glad to tie the game."
The homer came off starter Ryan Dempster, who allowed three hits in six innings.
"He just lifted that ball and got it up in the air — way, way, way up in the air — and it just kept carrying," Dempster said.
Uehara (4-1) fell four outs short of Bobby Jenks' major league record for a reliever of 41 consecutive retired batters set in 2007 and Mark Buehrle's mark for all pitchers of 45 in 2009. The run was the first off Uehara in 30 2-3 innings and ended a streak of 27 scoreless outings since July 9.
"I wasn't aware of it," Valencia said, "but I'm not surprised by it because he's got great stuff."
Valencia led off the ninth with a triple to center and pinch-runner Alexi Casilla scored easily on Wieters' fly to right.
Tommy Hunter (6-4) got the win with a perfect eighth. Jim Johnson got his AL-best 46th save.
"Koji's been so good for us," Boston manager John Farrell said. "Even after the run allowed, he continued to pitch as he has. It didn't faze him and he finished out the inning.