Martinez is coming off of a strong 2016 campaign. The right-hander finished the year with a 3.04 ERA over 195 1/3 innings, earning a 16-9 record.
With the deal, the Cardinals and Martinez avoid an arbitration hearing scheduled for Wednesday.
The Cardinals will have a bevy of options for their starting rotation this season. Martinez, Adam Wainwright, Mike Leake and Lance Lynn are locks. However, the Cardinals will have Alex Reyes, Michael Wacha, Luke Weaver and more to fill out the rotation.