Right-hander Michael Ynoa also was dealt to Chicago. Oakland obtained right-hander Chris Bassitt, catcher Josh Phegley, and infielders Rangel Ravelo and Marcus Semien.
Samardzija was 31-42 with a 3.97 earned-run average for the
Samardzija, who turns 30 on Jan. 23, is eligible for salary arbitration. He can become a free agent after the 2015 season.
"We're going to make every effort to make this a long-term relationship," General Manager Rick Hahn said. "We felt that this was a premium starter who fit, not just in terms of how he fit in our rotation, but how he fit in our clubhouse."
All-Star catcher Miguel Montero was traded to the Chicago Cubs in a deal that relieves the Arizona Diamondbacks of having to pay $40 million over the next three years.
Arizona received minor league right-handers Jeferson Mejia and Zack Godley in the trade.
Montero, 31, an All-Star in 2011 and 2014, hit .282 this year with 18 home runs and 86 runs batted in.
Mejia, 20, was 2-4 with a 2.48 ERA in two starts and 10 relief appearances this year for rookie-level Mesa. Godley, 24, was 4-3 with a 3.09 ERA and 15 saves in 40 games for Kane County and Daytona, both Class-A teams.
A person familiar with the negotiations said that Francisco Liriano, 31, is staying with the Pittsburgh Pirates, agreeing to a $39-million, three-year contract.
The person spoke on condition of anonymity because the agreement had not been announced.
The left-hander was 16-8 with a 3.02 ERA in 2013 for the Pirates. He was 7-10 with a 3.38 ERA in 2014.
A person familiar with the negotiations said that the Atlanta Braves have agreed to a one-year contract with free-agent infielder Alberto Callaspo, who batted .223 for the A's in 2014.