With Jon Lester pitching for Boston, Orioles right-hander Brad Bergesen knew he had little margin for error.

Bergesen matched the Red Sox left-hander for six innings, but wasn't around to see the end of Lester's latest masterpiece against the Orioles on Thursday night.

"You know Lester, his career against the Orioles — I knew just every pitch mattered tonight," Bergesen said after allowing two runs on six hits and picking up a no-decision in a 6-2 loss that dropped Baltimore into last place. "I think the biggest thing for me was the sixth inning, getting in that jam and being able to get out of it."

Lester improved to 14-0 all-time against Baltimore with eight dominating innings and the Red Sox averted a three-game sweep at Camden Yards.

Bergesen escaped trouble in the sixth when Adrian Gonzalez's double put runners on second and third with no outs. He fanned Kevin Youkilis and David Ortiz, issued an intentional walk to J.D. Drew to load the bases and then got Jarrod Saltalamacchia to fly out to the warning track in center.

Vladimir Guerrero tied the game at 2 with a solo homer in the bottom of the inning.

But the Red Sox went ahead in the seventh, using a swinging bunt by Dustin Pedroia to snap a 2-all tie two batters after Boston's Marco Scutaro failed to execute a sacrifice bunt following Carl Crawford's leadoff double against Jim Johnson (1-1).

"We got a break with the (missed) bunt and then they caught a break with the swinging bunt," said Johnson, "so it just kind of evened itself out."

Lester could only shake his head when asked why he fares so well against the Orioles.

"If I knew the answer to that, I'd do well against everybody," he said. "I just pitch well against this team. ... I just really don't know. I'm aware of the track record I have against them, but I don't know how to explain it. I feel comfortable against them. I really like pitching here at this park, I've always felt good here."

Lester (3-1) is unbeaten in 17 career starts versus the Orioles and boasts the longest active winning streak by any pitcher against one team. He yielded two runs on four hits, walked three and struck out five.

"He threw his changeup about as good as he's ever thrown," Red Sox manager Terry Francona said of Lester. "Some of those hitters, he really slowed them down. He was really good and he needed to be to give us enough time. He gave us a chance."

After Derrek Lee's RBI single in the first, Lester didn't allow another hit until Guerrero's solo homer with two outs in the sixth.

Baltimore fell into last place in the AL East, a half-game behind the Red Sox, who completed a nine-game road trip.

"It's great to finish up this road trip the way we did," Lester said. "The guys are starting to feel a little bit better about themselves now, and hopefully we can go home and really start playing well. To go 6-3 on this road trip, we'll take it, the way we started off the season."

Boston's Adrian Gonzalez had three hits and two RBIs.

Jacoby Ellsbury led off the game with a double and scored on Gonzalez's one-out double for a 1-0 lead.

The Orioles tied it in the bottom half when Brian Roberts drew a leadoff walk, moved to second on Nick Markakis' single, stole third and scored on Lee's single, which ended an 0-for-14 slump with runners in scoring position.

Ellsbury and Gonzalez teamed again to put the Red Sox up 2-1 in the third. Ellsbury singled with one down, moved to second on a groundout and came home on Gonzalez's single.

Guerrero tied it in the sixth with a shot to left off a full-count fastball from Lester, who surrendered a home run for the first time in five starts. It was Guerrero's fourth homer of the season.

Still, it didn't give Bergesen anything to show for a decent outing.

"The body of work was pretty good. I thought (Bergesen) gave us a good chance to win against a good-hitting club, and I was proud of him," Orioles manager Buck Showalter said.

In the eighth, the Red Sox loaded the bases with none down before Saltalamacchia's RBI single off Michael Gonzalez made it 4-2. Two outs later, Ellsbury looped a two-run single to center.

NOTES: Ellsbury and Gonzalez have each doubled in four straight games. ... Orioles LHP Brian Matusz, on the 15-day disabled list since March 30 with a strained left intercostal muscle, is headed to the team's Sarasota, Fla., facility after throwing a pain-free 35 pitches from the mound in a bullpen session before Thursday's game. ... Baltimore SS J.J. Hardy, who has been on the 15-day DL since April 10 with strained left oblique, took dry swings, hit off a tee, threw from 120 feet and ran sprints in Sarasota on Thursday. Manager Buck Showalter said Hardy was scheduled to take ground balls Friday. ... The Rays-Red Sox game postponed by rain April 13 will be made up as the 1:05 p.m. portion of a day/night doubleheader at Fenway Park on Aug. 16. ... RHP Chris Jakubauskas (right groin strain) will pitch for the Orioles' Triple-A Norfolk affiliate Sunday as part of a rehabilitation assignment. He is eligible to come off the 15-day disabled list May 2. ... Baltimore is 1-11 when scoring three runs or less.