The Pittsburgh Pirates signed right-hander Charlie Morton to a three-year, $21 million contract extension Wednesday that could be worth up to $30 million, betting on the 30-year-old to continue a successful return from Tommy John surgery and hedging against the increasing price of starting pitching, sources told Yahoo Sports.

Morton’s extension represents the biggest deal given out at an otherwise-slow Winter Meetings and the largest for a pitcher in Pirates franchise history. He returned from reconstructive elbow surgery in June and posted a career-best 3.26 ERA over 20 starts and 116 innings, leading starters with a 62.9 percent groundball rate, the second-highest mark for any starter over the last five seasons.

“The most important part of this deal and the reason why this deal got done is Charlie wanted to remain a Pirate and considers himself a Pirate,” said Morton’s agent, Andrew Lowenthal of Jet Sports Management, who confirmed the deal to Yahoo Sports. “He loves the city. He loves the fans. The team stuck by him. This is Charlie’s way of being loyal to the organization. The contract is a win-win.”

Morton, who would have been a free agent following the 2014 season, will receive $4 million this season, $8 million in 2015 and $8 million in 2016. The contract includes a club option for the 2017 season worth $9.5 million with $500,000 in potential incentives and a $1 million buyout. Should Morton be traded, the club option turns into a mutual option. If triggered and Morton declined his end, he would forfeit the buyout.