Right-hander Johnny Cueto decided not to exercise the opt-out clause in his contract Saturday night, tying him to the San Francisco Giants for the next four seasons.

Cueto, 31, had until midnight on Saturday to make a decision. He is under contract with the Giants through 2021 and is scheduled to make $21 million per season.

The Giants hold a club option worth $22 million for the 2022 season. If they decline, Cueto is owed a $5 million buyout.

“Johnny is excited about remaining with the Giants and his goal remains to win a World Series in San Francisco,” agent Bryce Dixon told the San Francisco Chronicle in a text message.

Cueto had indicated at the end of this season that he was likely to decline his opt-out clause.

Cueto is 26-13 with a 3.48 ERA in two seasons with the Giants. The two-time All-Star signed with San Francisco on Dec. 16, 2015, after helping the Kansas City Royals win the World Series after Kansas City acquired him at the trade deadline from the Cincinnati Reds.

He has a career mark of 122-83 with a 3.33 ERA in 283 starts over 10 major league seasons.