Right-handed pitcher Lance Lynn agreed to a three-year, $22 million contract with the St. Louis Cardinals on Thursday.

The deal comes two days after Lynn filed for arbitration. Lynn had three years left of arbitration eligibility, but the deal buys out those years. However it doesn’t cover any of his free-agent years, and Lynn is expected to be a free-agent after the 2017 season, according to MLB.com. Last year he made $535,000.This year he will make $7 million and the next two years he will make $7.5 million. In 2016 he can make $500,000 in performance bonuses and $1 million in 2017.

'His performance has led to much success for both he and the Cardinals organization,'' Cardinals general manager John Mozeliak said in a statement. ''We look forward to his continued growth as both a pitcher.”

Lynn had wanted to stay with the Cardinals. He wanted to remain in St. Louis because he didn't want to worry about having a job. It is unknown where he would of ended up had he had an arbitration hearing.

Lynn was the Cardinals first-round pick in the 2008 draft. He made his major league debut in 2011. Last year he had the best year of his career so far as he was 15-10 with a 2.74 ERA, which was a career best, in 33 starts, according to the Associated Press. Lynn has a career record of 49-28 with a 3.46 ERA. He has become one of the best pitchers in the National League. When you combine his stats from 2013 and 2014 he is first in games started (66), fifth in quality starts (43), sixth in wins (30, seventh in strikeouts (379), eighth in innings pitched (405 and one third), and 14th in ERA (3.35)among National League pitchers.

The Cardinals still have three players that are eligible for arbitration, outfielders Jon Jay and Peter Bourjos and backup catcher Tony Cruz.