The Cubs had scored exactly one run in each of their previous five games. David Bote ended that streak with a two-run homer in the fifth, and Lester (14-5) allowed a run and seven hits in 5 2/3 innings.
Five Chicago relievers finished. Pedro Strop came in with the bases loaded in the eighth and walked in a run, but he retired James McCann on a grounder to end that threat with the Cubs still up 4-2.
Javier Baez and Anthony Rizzo hit consecutive homers in the ninth for Chicago to break the game open. Baez's drive, a three-run shot, was his 26th of the year.
Francisco Liriano (3-9) allowed four runs and seven hits in 5 1/3 innings.
Daniel Murphy singled home a run in the fifth in his first game with the Cubs after being acquired in a trade from Washington on Tuesday.
Lester, who pitched six innings in a 1-0 win over Pittsburgh last Thursday, was sharp again in Detroit. He allowed an RBI single to Ronny Rodriguez in the second, but that was all the scoring against him for Detroit.
Liriano didn't get out of the second inning in his previous start, but he blanked Chicago for the first four innings before running into trouble in the fifth. The first six Chicago hitters of that inning reached base, and Bote's drive put the Cubs up 2-1, snapping an 0-for-16 drought for the Chicago third baseman.
Murphy added his RBI single, although a baserunning blunder by Willson Contreras and a double-play grounder by Rizzo helped Liriano escape the inning with only three runs in.
Contreras hit an RBI infield single in the sixth to make it 4-1.
The NL Central-leading Cubs snapped a three-game losing streak.
Cubs: Chicago put SS Addison Russell on the 10-day disabled list, retroactive to Monday, with a sprained left middle finger.
Tigers: LHP Daniel Norris (left groin strain) made a rehab start with Class A Lakeland on Tuesday night at Daytona, throwing three innings.
Cubs: Chicago starts a four-game home series against Cincinnati on Thursday night. Cole Hamels (3-0) takes the mound for the Cubs against Anthony DeSclafani (6-3).
Tigers: Detroit opens a four-game set against the visiting Chicago White Sox on Thursday. Matthew Boyd (7-11) takes the mound for the Tigers against James Shields (5-14).