BOSTON — The Boston Red Sox got off to a promising start Tuesday night. What they lacked was a finish.

Dustin Pedroia’s leadoff homer was one of only three hits for the Red Sox in a 3-2 loss to the Baltimore Orioles, who rallied from a 2-0 deficit.

Danny Valencia tripled to stop closer Koji Uehara’s streak of 37 consecutive outs in the ninth inning and Matt Wieters followed with the go-ahead sacrifice fly for the Orioles.

“Just a number of missed opportunities early on,” Boston Manager John Farrell said.

Boston went without a hit from Mike Carp’s double in the second inning until Jarrod Saltalamacchia’s single up the middle in the ninth. The Red Sox failed to capitalize on six walks and were 0 for 4 with runners in scoring position.

“We were in it. We just didn’t get the final push,” Saltalamacchia said.

Brian Roberts’ run-scoring groundout in the fifth pulled Baltimore within 2-1, then Chris Davis’ 51st homer of the season in the sixth made it 2-2. Davis broke the club record set by Brady Anderson in 1996.

Uehara (4-1) fell four outs short of Bobby Jenks’ major league record for a reliever of 41 consecutive retired batters set in 2007; Mark Buehrle holds the record for all pitchers with 45 in 2009. The run was the first off Uehara in 302/3 innings and ended a streak of 27 scoreless outings since July 9.

“You don’t like your chances there with (Uehara) but we got a big hit from (Valencia),” Orioles Manager Buck Showalter said.

Valencia led off the ninth with a triple to center and pinch-runner Alexi Casilla scored easily on Wieters’ fly to right.

“At the time of the game, that’s the difference for us,” Farrell said. “But Koji’s been so good for us. Even after the run allowed, he continued to pitch as he has. Didn’t faze him and he finished out the inning.”

Boston’s three-game winning streak came to an end but the magic number to clinch the AL East dropped to three thanks to Texas’ 7-1 victory against Tampa Bay.

Jim Johnson worked the ninth for his AL-best 46th save for the Orioles, who remained two games out in the AL wild-card race.

The Orioles threatened in the eighth when Nate McLouth singled and took third on Manny Machado’s AL-leading 51st double with no outs. But Craig Breslow replaced Brandon Workman and needed just six pitches to get out of the jam. With the infield in, he got Davis and Adam Jones to ground out to shortstop Stephen Drew as the runners held, then retired Nick Markakis on a fly to left.

“I put him in a bad spot and he pitched exceptionally in that role,” Farrell said.

NOTES: The Red Sox stole three bases and have been successful in their last 35 attempts.