The Red Sox lead the second-place Orioles by 1 1/2 games in the American League East. Boston has dropped 14 of its past 19 matchups with Baltimore.
"This is going to be a very highly competitive division throughout the course of the summer," Boston manager John Farrell said. "[The Orioles] got good players. It's a very well put-together team and they have good players. I think we do, too."
Lester had his second consecutive shaky outing, allowing five runs on nine hits with eight strikeouts and no walks in five innings. Entering the game, Lester had been 7-0 with a 2.52 ERA in 10 starts in Baltimore. He has not won since May 15.
"This team counts on me to throw innings," Lester said. "I have not done that. I need to do a better job going deeper into the game."
Orioles starter Miguel Gonzalez had another solid outing. He allowed three runs on five hits with two strikeouts and two walks over 6 1/3 innings.
Jacoby Ellsbury had two hits for Boston, while Jose Iglesias extended his hitting streak to 17 games with an eighth-inning single.
Chris Davis went 2-for-4 and hit his Major League-leading 23rd home run for the Orioles. Manny Machado also went 2-for-4 to record his 29th multihit game, also best in the Majors. Nick Markakis had four hits, including two doubles, and scored three runs.
"Anytime we can rattle off some wins against a division opponent it's a good thing, especially these guys, knowing they're in first place," said Davis, who entered the game 0-for-14 against Lester. "We're definitely happy the way the series went."
Adam Jones provided Baltimore a 1-0 lead in the third on a two-out double to right that scored Markakis, who opened the inning with a single. Davis then followed with a towering home run to right-center that was also the 100th of his career.
Meanwhile, the Red Sox had trouble mustering any offense against Gonzalez, as a single by Ellsbury was their only hit through five innings.
"I thought I did a pretty good job, just keeping my teammates in the ballgame," Gonzalez said. "It's fun to watch our guys hit, especially against Lester, he's been doing a great job this year and always pitches well against us."
The Orioles increased their lead to 5-0 in the fifth on an RBI single by Machado and a double by Davis. The Red Sox got on the board in the seventh when Will Middlebrooks hit his ninth homer of the season, a three-run shot to cut the margin to 5-3 and end Gonzalez's day.
"Baltimore is obviously a good team, a good pitching staff, but do I think we're better? Of course," Middlebrooks said. "The ball didn't bounce our way all the time. I wish I could have done more and we'll go get them on Tuesday."
Also in the seventh, Mike Carp had to leave the game after his right hamstring tightened up while legging out a double. With no game scheduled for Monday, Carp hopes to be ready for Tuesday's doubleheader against Tampa Bay.
"Hopefully, it's just a cramp," Carp said. "It's been pretty humid the last couple of days. I don't feel too concerned about it. I have the rest of the night off and tomorrow. Almost two full days until we play again, so I'm pretty confident I'll be back out there Tuesday."