The Sacramento Kings have agreed to a three-year contract extension with forward Rudy Gay, sources told ESPN.com.

So Far, So Good Advanced statistics haven't always been kind to Rudy Gay over his career, but that has changed so far this season with the Kings. Value Career Rank PER 22.1 1st Win shares per 48 .181 1st True shooting pct. 56.8% 1st Assist pct 17.9% 1st -- ESPN Stats & Information

The contract will pay Gay $40 million and includes an opt-out clause before the 2017-18 season, Yahoo! Sports first reported. Gay is currently in the final year of a contract that is paying him $19.3 million this season.

Gay, 28, has been productive since the Kings acquired him in a trade with the Toronto Raptors last December. He shot 48 percent in 55 games with the Kings last year, the best shooting of his career as he meshed well in coach Mike Malone's system. He is averaging 22.5 points over the first 10 games if his season, which is a career-high rate.

The Kings recruited Gay like he was a free agent last summer when he had a choice to opt out of his contract. The sides then conducted contract extension talks throughout the fall before reaching an agreement over the weekend.

Sacramento is off to a 6-4 start following a victory over the San Antonio Spurs on Saturday night.