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.
More from ESPN.com
Boston players were reminded things won't be easy in October by Tuesday's seemingly run-of-the mill 3-2 loss, writes Tony Lee. Blog
"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.
The Red Sox took a 1-0 lead on Pedroia's ninth homer of the season. Left fielder McLouth didn't even move as it went deep into the seats above the Green Monster.
They made it 2-0 in the fourth with the help of two errors by a team that had made just 43 all year.
With one out and third baseman Machado playing in short right field on the shift for Saltalamacchia, he charged a hard grounder and let it get by him for an error. Drew then walked before a double steal put runners at second and third. Xander Bogaerts followed with a low liner to left field that McLouth charged. The ball hit off his glove for an error and Saltalamacchia scored. Bogaerts was credited with a sacrifice fly.
Machado made a throwing error in the seventh on a grounder down the line by Pedroia.
The Orioles made it 2-1 in the fifth when Valencia walked, took third on a double by J.J. Hardy and scored on a groundout by Roberts.
The Red Sox stole three bases and have been successful in their last 35 attempts. ... Baltimore's total of errorless games remained at 113, tied with Houston's total in 2008 for the most since 1900. ... Wei-Yin Chin (7-7) pitches for Baltimore against Jake Peavy (3-1) in the second game of the three-game series Wednesday night. ... The Red Sox recalled IF Brock Holt, and RHPs Brayan Villarreal and Steven Wright from Triple-A Pawtucket.
Copyright by STATS LLC and The Associated Press
BOSTON, MA - SEPTEMBER 17: David Ortiz #34 of the Boston Red Sox takes batting practice before a game with...