BOSTON – The Detroit Tigers have the best pitcher in the American League and the best hitter in baseball.

Jon Lester was better than both.

Lester outdueled Max Scherzer and retired Miguel Cabrera with the bases loaded Tuesday night as the Boston Red Sox beat Detroit 2-1 in a well-played game between division leaders.

It ended Scherzer’s chance to become just the second pitcher to open a season with a 20-1 record.

“We all know who we’re facing tonight and what he’s done this season,” Lester said, “but I can’t worry about Max Scherzer. I have to worry about the other nine guys in the lineup.”

The Tigers lead the AL in hitting and Cabrera leads all batters with a .355 average.

So the Red Sox were in big trouble when he came up with the bases loaded and two outs in the fifth inning with Detroit leading 1-0.

Lester’s first two pitches were balls, but he recovered to get Cabrera to ground to shortstop Stephen Drew for a forceout at second base.

“The key to the game,” Red Sox Manager John Farrell said.

“Obviously I don’t want to be in that situation with him up,” Lester said, “the best hitter on the planet. You’re trying to really minimize damage.”

Boston scored on Will Middlebrooks’ two-run single in the fifth after Jose Iglesias doubled in a run in the second for Detroit.

Koji Uehara pitched the ninth for his 17th save in 20 opportunities and extended his scoreless streak to 25 innings as Boston won for the eighth time in 10 games.

Lester (13-8) lowered his ERA to 1.71 in his past six starts. He allowed one earned run and eight hits with a season-high nine strikeouts and no walks in seven innings.

Scherzer (19-2), who won his first 13 decisions, lost for the first time since July 13 when the Texas Rangers beat him, 7-1.

“For me it’s a team thing,” he said. “If I win 20 it’s a team achievement.”

Scherzer can thank his hitters for many of those wins. The 7.17 runs per nine innings they scored for him going into his 28th start were the most among AL pitchers.

But Lester shut them down.

“He was totally different than the first time we faced him,” Torii Hunter said. “He was the Jon Lester of old.”

Lester struggled for nearly two months before the All-Star game. In one game he allowed five runs in 52/3 innings against the Tigers, but he’s 5-2 since the break.

“It was a well-pitched game on both sides,” Farrell said. “We didn’t have anything going against Scherzer until the two-out base hit by Will for the two RBI. Jon was very good when we needed it.”

Roger Clemens is the only pitcher to start off at 20-1 and ended up 20-3 with the New York Yankees in 2001. Rube Marquard was the only other pitcher with a 19-1 record, but lost his next decision in 1912 with the New York Giants.

The Tigers lost for the second time in six games despite the return of Cabrera, who missed three games with abdominal and groin problems. He went 0 for 4.

NOTES: Boston starters have allowed three runs or fewer in 13 of its past 14 games. … Detroit’s Victor Martinez extended his hitting streak to 10 games with a single in the eighth. … Red Sox CF Jacoby Ellsbury missed the game with a sore thumb.