CHICAGO -- The Chicago Cubs agreed to terms with free-agent infielder/outfielder Ben Zobrist and traded second baseman Starlin Castro to the New York Yankees to make room for Zobrist at second base, the teams announced Tuesday.

Zobrist's deal is for four years and $56 million. It includes a full no-trade clause for the first three years.

Zobrist will receive a $2 million signing bonus up front, then will be paid $10 million in salary during the 2016 season. He will make $16 million, $16 million and $12 million the final three years of the deal.

The Cubs received pitcher Adam Warren and, according to ESPN sources and multiple reports, second baseman Brendan Ryan from the Yankees in return for Castro, who spent six seasons with the Cubs and made the All-Star team three times.

"We could not have made this signing without this trade and would not have made this trade without this signing," Cubs president of baseball operations Theo Epstein said. "This was an opportunity to essentially trade Starlin for Ben Zobrist and Adam Warren. That made a lot of sense for us."

The move reunites Zobrist, 34, with his former manager in Tampa Bay, Joe Maddon.

Free agent Ben Zobrist, who helped the Royals win their first World Series title in 30 years, has agreed to terms with the Cubs, which reunites him with his former manager, Joe Maddon. Doug Pensinger/Getty Images

"He's all about winning. That's what he's about," Maddon said earlier Tuesday.

Zobrist was a key part of the Kansas City Royals' 2015 championship team. He batted .303 with two home runs, six RBIs, 15 runs scored and one stolen base as the team's No. 2 hitter throughout the postseason. He went 3-for-6 with two doubles in Game 1 of the World Series to set the tone early for Kansas City. He contributed two doubles and scored two runs in Game 5 to help the Royals defeat the New York Mets and clinch their first title since 1985.

"Ben is a winning baseball player," Epstein said. "His offense, his defense, his baserunning. He's been one of the more valuable players in the game for a long time."

Second Thoughts For Cubs The Cubs are banking Ben Zobrist, whose 39.3 wins above replacement ranks fifth among all position players since 2009, will immediately upgrade their second base production, which ranked among the NL's worst last season. Cubs 2B in '15 Stats NL Rank BA .250 11th OBP .303 13th Slugging pct. .383 9th Strikeout pct. 22.8 13th Zobrist: .276 BA, .359 OBP, .450 SLG, 10.5 K pct.

Kansas City acquired the switch-hitting Zobrist in a trade with the Athletics days before the July trade deadline. Prior to his stint in Oakland, the two-time All-Star had spent his entire nine-year career with the Rays. Zobrist's 2006 rookie year coincided with Maddon's first season in Tampa Bay.

A versatile defender, Zobrist has seen significant playing time at several positions, including second base, shortstop and right field.

"I thought there should have been a super-U player on the All-Star team," Maddon said when discussing Zobrist's value as a utility player. "It's an absolute position, just like second base or left field is. A real, legitimate SU guy is a position, and it permits you to do so many different things with your lineup daily and so many different things to get progress daily."

Zobrist is a career .265/.355/.431 hitter, and his .355 on-base percentage would have tied with Kyle Schwarber for third on the Cubs the past season, according to ESPN Stats & Information. He batted .276 with 13 home runs and 56 RBIs during the 2015 regular season, numbers on par with his career averages.

"He helps shape our offense a little bit more," Epstein said.

Zobrist is a native of Eureka, Illinois, which is approximately 140 miles southwest of Chicago.

ESPN's Jesse Rogers, Buster Olney, Andrew Marchand and Jim Bowden and The Associated Press contributed to this report.