The deal is for six years and $155 million, a source confirmed to ESPNChicago.com's Jesse Rogers.
Among other incentives negotiated by Lester and his agents, Seth and Sam Levinson, the deal includes a signing bonus of $30 million to be paid over the life of the contract and a full no-trade clause. Lester will earn $145 million between his base salary and signing bonus and receive either a $10 million buyout after six seasons or a $25 million vesting option for the 2021 season that could bring Lester's total take to $170 million, a source familiar with terms of the contract told ESPN.com's Jayson Stark.
The option would vest if Lester pitches at least 200 innings in 2020 or at least 400 in the 2019 and 2020 seasons combined.
He also gets access to 25 hours of personal flights on a private plane per year.
Lester took to Twitter on Wednesday morning to react to the agreement.
The reported average annual value of $25.8 million would be the second highest for a pitcher behind Clayton Kershaw's $30.7 million as part of a $215 million, seven-year deal with the Los Angeles Dodgers that began in 2014, and would be the highest ever given to a free-agent pitcher on a multiyear deal.
New manager Joe Maddon, who said he got a text message with the news about a half-hour before word spread, called Lester the Cubs' "Plan A."
"It's not often you get to win the lottery," he said. "We won the baseball lottery so far this year, but now it's up to us to put it into effect. It's all theory right now. We've got to make it real, but you need pieces like this to make it real."
Maddon said he was eager to hear why Lester chose the Cubs.
"He's been [to the World Series] before. He understands what it feels like. I want to believe that he could foresee the same thing happening here," Maddon said.
The manager noted that he said in his opening news conference that he believed the Cubs were a playoff team, but added that he thought they could contend sooner with the addition of Lester.
"Yeah. It definitely sends that message about how [Cubs president Theo Epstein] and the group feels about this particular group, but understand we have a lot of young players that have to grow up, and we have to do a good job of nurturing that and making it happen," Maddon said. "It's possible, but having Jon there definitely adds to the flavor and the believability."
After signing Lester, the Cubs' odds of winning the World Series jumped to 12-1 from 18-1 at the Westgate Superbook in Las Vegas.
New teammate Jake Arrieta tweeted his approval of the move Wednesday.
The Cubs are on a streak of five straight losing seasons. They haven't made the playoffs since 2008, and their championship drought dates to 1908.
Epstein and general manager Jed Hoyer are working to turn that around. Reuniting with Lester is the latest step -- Epstein was the Red Sox GM before joining the Cubs and Hoyer was the assistant GM in Boston, where Lester spent nearly all of his nine-year career. They also brought on Maddon, a top-tier manager who left the Tampa Bay Rays and signed a $25 million, five-year contract with the Cubs.
The Cubs also have a promising core of young players, and have added to the roster this week by acquiring catcher Miguel Montero in a trade with Arizona and bringing back starting pitcher Jason Hammel.
Maddon hopes Lester will help change the clubhouse mindset as soon as spring training starts in February.
"It definitely makes it more believable to everybody else in that room," he said. "I'll stand up and make the same speech regardless, but when you have it backed up by that particular kind of presence, it adds to it."
He had narrowed it to the Cubs and Red Sox earlier Tuesday, with Giants general manager Brian Sabean confirming his team was out and sources telling ESPN the Dodgers also had been eliminated. In saying no to San Francisco, Lester called Sabean, manager Bruce Bochy and catcher Buster Posey to thank them for their respect in the process.
The Red Sox's offer was for six years and $135 million with no vesting option, a major league source told ESPNBoston.com's Gordon Edes.
Boston outfielder Shane Victorino was sad to see his former teammate decide not to return to the Red Sox, but wished him well in the Windy City on Twitter.
Red Sox GM Ben Cherington previously acknowledged indirectly that Lester could elect to go elsewhere.
"We need to build a rotation, and we need to be in on all sorts of stuff, and we have been in on all sorts of stuff," Cherington said late Monday. "There are probably 15 to 20 starting pitching scenarios we've talked about and worked on. Not all of those are going to land; more won't than will. But we're working as hard as we can. We're going to build a good rotation."
The Cubs had remained confident they could land Lester.
"This is his life and his decision, and everyone should give him space to evaluate the options and get together with his family and make a decision," Epstein said earlier Tuesday. "I'm not caught up at all with the timing of it."
Lester, who will turn 31 next month, went 6-4 with a 2.35 ERA for the Oakland Athleticsafter he was acquired in a blockbuster trade-deadline deal with the Red Sox in exchange for outfielder Yoenis Cespedes. Overall, he was 16-11 with a career-best 2.45 ERA in 2014.
He was on the hill for the A's in the American League wild-card game against the Kansas City Royals, and left in the eighth inning with runners on first and second with one out and his team leading 7-4. The Royals eventually won the game 9-8 in 12 innings.
He is noted for his performance in the postseason, in which he has a solid 6-4 record and 2.57 ERA in 14 appearances. He has been dominant in the World Series, where he is 3-0 with a 0.43 ERA in three starts, helping the Red Sox win two championships.
Lester, who has a career mark of 116-67 with a 3.58 ERA in nine seasons, rejected a four-year, $70 million contract extension offer from the Red Sox in the spring. He was paid $13 million this past season.
ESPN's Jim Bowden, ESPN The Magazine's Buster Olney, ESPN.com's Jayson Stark, ESPNLosAngeles.com's Mark Saxon and The Associated Press contributed to this report.