SAN DIEGO - All-Star catcher Miguel Montero was traded from Arizona to the Chicago Cubs on Tuesday in a deal that relieves the Diamondbacks of having to pay $40 million over the next three years.

Arizona receives minor league right-handers Jeferson Mejia and Zack Godley in the swap.

The 31-year-old Montero, an All-Star in 2011 and '14, hit .282 this year with 18 homers and 86 RBIs. He is owed $12 million next season and $14 million in each of the final two years of a $60 million, five-year contract.

Montero tweeted soon after the trade: "Excited for the next chapter in my career with a team with so much history and a bright future. See you soon Windy City!"

And later in the day, the Cubs gave him an ace to catch when they agreed to a $155 million, six-year contract with Jon Lester.

Mejia, 20, was 2-4 with a 2.48 ERA in two starts and 10 relief appearances this year for rookie level Mesa. The 24-year-old Godley was 4-3 with a 3.09 ERA and 15 saves in 40 games for Kane County and Daytona, both Class A teams.

"We had an opportunity to get two good arms," Diamondbacks general manager Dave Stewart said. "Mejia is a power arm, a 6-7 kid, has 94-97 (mph). Godley is a kid that's 92-96. . .. We needed to get starting pitching back into our system. Did we give up a pretty good value? Yes, we did. But we do think that we got good value back."

Stewart said that while the Diamondbacks save money, he doesn't think it's wise to spend it on free agent pitching right now. He said he thinks next year's market will be better.

"To move Miggy was a difficult decision," Stewart said. "It was not one that we took lightly, but you only have so many pieces, so many moves, that you can do to get to where you want to."

The lefty-swinging Montero could share time with Welington Castro, who batted .237 with a career-high 13 homers this season but hit only .216 against right-handed pitchers.

"It really gives us a solid presence in the catching position," new Cubs manager Joe Maddon said. "It's a tremendous new addition — a first step building into this winter. ... Really excited about."