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.
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 on Tuesday were the most among all 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 5 2/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 RBIs. 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.
Scherzer rebounded from his worst start of the season and allowed two runs and five hits with eight strikeouts and three walks before leaving with runners at first and second and no outs in the eighth.
He struck out the side in the first, allowed a single in the second and then pitched two perfect innings.
He started the fifth by striking out Mike Carp before Jonny Gomes singled. Drew followed with a ground-rule double that went into Boston's bullpen in right-center field on one hop. After David Ross struck out, Middlebrooks put Boston ahead 2-1 with a single to center on a first-pitch slider.
"You may get one good pitch in an at-bat to hit (against Scherzer)," Middlebrooks said. "You can't miss it."
The Tigers got base runners against Lester in four of the first six innings, but he worked out of three of those jams.
In the second, Omar Infante singled and reached third on a two-out single by Brayan Pena. Iglesias then lined a double that drove in Infante, but Pena was thrown out at home.
Lester retired the next seven batters, four on strikeouts, before Pena reached first on a fielding error by third baseman Middlebrooks with one out in the fifth. Iglesias struck out before singles by Austin Jackson and Hunter loaded the bases. But Lester retired Cabrera.
Detroit threatened again in the sixth when Prince Fielder singled and took second on a one-out single by Infante. But Lester struck out Matt Tuiasosopo for the third time and retired Pena on a fly out.
Scherzer "pitched terrific. Early on I thought he was as sharp as he's been all year," Tigers manager Jim Leyland said. "Tonight, Lester pitched better."
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. ... Rick Porcello (11-7) pitches for Detroit against Ryan Dempster (7-9) in the finale of the three-game series on Wednesday night.
Copyright by STATS LLC and The Associated Press
BOSTON, MA - SEPTEMBER 3: Miguel Cabrera #24 of the Detroit Tigers throws before the game between the Boston Red...
32,071 (86.5% full) - % is based on regular season capacity
76 degrees, cloudy
Home Plate - Paul Schrieber, First Base - Jeff Kellogg, Second Base - Mike Muchlinski, Third Base - Eric Cooper
A rare loss for Max Scherzer tonight to say the least:
2nd loss this season (19-2)
1st ROAD loss since July 30, 2012 (also at Boston)
1st loss with 2 or fewer runs and at least 7 IP since July 16, 2011 (home vs White Sox)
1st career loss with at least 8 K and 0 HR allowed
From Elias: Victor Martinez has gone a career high 71 straight PA without striking out. Over that stretch he's batted .403.