BALTIMORE – David Ortiz put his bat to good use, Jon Lester rekindled his dominance of the Baltimore Orioles, and the Boston Red Sox climbed back into first place in the AL East.

All in all, the Red Sox couldn’t have found a better way to end a whirlwind weekend.

Lester allowed four hits over seven innings, Ortiz went 4 for 4 with his 20th home run and Boston used a 5-0 victory Sunday to earn their first series win over the Orioles in two years.

As a bonus, the Red Sox took a half-game lead over Tampa Bay, which lost to the Yankees. Boston stood atop the division for 60 straight days before a defeat Friday night ended the run. The Rays visit Fenway Park for a makeup game Monday night.

Mike Napoli had two doubles and an RBI for the Red Sox, who took two of three from the third-place Orioles. Boston had lost six straight series to Baltimore since a four-game sweep in July 2011.

All four hits against Lester (10-6) were singles. He struck out eight, walked two and did not allow a runner past second base. The right-hander improved his lifetime record against the Orioles to 15-2, although he lost his previous two decisions against them.

“They’ve always been a tough team to pitch against,” Lester said of the Orioles. “They’ve always had a great offensive lineup.

“Our guys did a good job today with (Orioles starter Jason) Hammel, making him work and giving me a couple of runs, giving me a cushion to work with.”

On Saturday night, Ortiz shattered the casing of two dugout phones with his bat after being ejected from the game. On Sunday, he opted to take his swings at Baltimore pitchers.

Asked if he took a different attitude into the game because of his outburst on Saturday, Ortiz replied, “No, no. It’s the opposite. You’ve got to make sure you don’t get out of your game. Sometime when you get excited it gets worse. Just go out there like I normally do.”

Ortiz hit a two-run shot off Hammel (7-8) in the third inning to put Boston up 3-0. Big Papi has 12 consecutive 20-homer seasons, the last 11 with Boston. Only Ted Williams, with 16, had more as a member of the Red Sox.

Ortiz also had three singles, tying his season high in hits.

“After taking it out on the phone … he took it out on the baseball today,” Manager John Farrell said. “It was good to see.”

With Ortiz and Lester leading the way, the Red Sox got a coveted victory.

“Especially in this situation where we are fighting with Tampa for first place,” Ortiz said. “It’s something we need.”

Hammel allowed three runs, six hits and a career-high tying five walks in 51/3 innings. The right-hander is 0-6 with a 5.63 ERA in 10 starts since May 27.

“It’s obviously very frustrating. I am not doing what I know I can do,” Hammel said. “But it could be a lot worse. If I was in my younger years, I would get myself into trouble like that, then you could really implode. So that’s not happening.”

Baltimore’s Chris Davis went 0 for 4 with two strikeouts. He has not added to his major league-leading home run total of 37 since July 14, and he has struck out in 22 straight games — including 10 in the last four games.

It was only the fourth time this season the Orioles have been blanked, tied with Tampa Bay for lowest in the AL.

Blame it on Lester, their old nemesis.

“You know what you’re going to get with him,” leadoff hitter Nick Markakis said. “You know it’s going to be a battle. He wasn’t locating his pitches the best I’ve seen him. But he was still effective, especially with guys on base.”

Hammel needed 27 pitches to get out of a rocky first inning. After a two-out RBI double by Napoli put runners at second and third, Mike Carp struck out.

Ortiz made it 3-0 in the third with an opposite-field drive to left following a single by Jacoby Ellsbury.

In the eighth, Ortiz singled and Napoli doubled before Jarrod Saltalamacchia hit a two-run single.

NOTES: Baltimore recalled outfielder L.J. Hoes from Triple-A Norfolk and designated pitcher Jairo Asencio for assignment. Hoes went 0 for 3 in his third major-league game. … Boston improved to an AL-best 20-11 in day games. … Baltimore fell to 9-5 in the pivotal game of a three-game series. … Napoli has had multiple extra-base hits in 11 games this season. … Ortiz has reached base in 32 of his last 34 games.