On February 2, 2017, it was announced that Martínez had signed a five-year extension with the St. Louis Cardinals worth 51 million dollars. On April 2, 2017, Martinez pitched his first Opening Night start of his career, playing the defending World Series champion Chicago Cubs at Busch Stadium. He struck out 10 and allowed no walks and six hits over innings. He received a no-decision as Randal Grichuk hit a walk-off bases-loaded single in the bottom of the ninth. At Yankee Stadium on April 15, Martínez struck out 11 batters, and walked eight, becoming the first to record both those marks in the same game since Randy Johnson in 1993. Martínez completed innings in a 3−2 loss to New York. On June 10, Martinez pitched both his first career complete game and shutout while allowing four hits as the Cardinals defeated the Philadelphia Phillies 7–0.