Clay Buchholz and the Red Sox agreed to a four-year deal Sunday that keeps the All-Star pitcher under contract with Boston through 2015.

The deal also includes club options for 2016 and 2017. Buchholz gives up three potential arbitration years and delays his chance to become a free agent in exchange for the security of a long-term deal.

"I think that's what every player wants," he said. "You're not going to play this game forever."

Buchholz said he considered taking his chances in arbitration and then becoming a free agent.

"If it was me and I didn't have a wife and kid, it might have been a decision I would have dealt with a little more," he said. "But from the first time we started talking about it, I did what my gut told me."

The 26-year-old Buchholz was second in the American League with a 2.33 ERA last year — the youngest Red Sox pitcher with an ERA that low since 1918. He was also among the league leaders with 17 wins, a .708 winning percentage and a .226 batting average allowed.

In his career, Buchholz is 29-23 with a 3.77 ERA. He pitched a no-hitter in his second major league start.

This season, the right-hander is 0-2 with a 7.20 ERA in two starts, including a 9-4 loss to the New York Yankees on Saturday.

"We think very highly of Clay or we wouldn't be doing this," Red Sox general manager Theo Epstein said, noting that Buchholz is under the team's control until age 31. "We expect Clay to be pitching very well at that point."