Bobby Marks examines James Harden's contract extension with the Rockets and what it means for Houston's pursuit of Carmelo Anthony. (1:21)

James Harden and the Houston Rockets have agreed to a four-year extension, the team announced Saturday. The contract is a supermaximum extension that will guarantee him $228 million through the 2022-23 season, league sources told ESPN.

Harden, the runner-up to Russell Westbrook for the NBA's MVP this season, has two years and $59 million left on his current contract. The four-year extension carries a value of $170 million and is the richest extension in NBA history.

The Rockets have fast-tracked the Harden extension with the arrival of All-Star guard Chris Paul and are turning full attention to completing a deal with the New York Knicks to acquire eight-time All-Star forward Carmelo Anthony in a trade, league sources said.

With the megadeal, Harden is taking advantage of brand-new CBA rules that enable contract extensions for superstars. He became eligible to add four years to his deal after making the All-NBA team in May, and the Rockets became focused on locking him into an extension after their season ended.

"Houston is home for me," Harden said in a statement released by the Rockets. "[Owner Leslie Alexander] has shown he is fully committed to winning, and my teammates and I are going to keep putting in the work to get better and compete for the title."

Part of the pitch was the Rockets' activity this offseason, as they've been one of the most aggressive teams in the summer at adding talent and convincing Harden to give the organization a long-term commitment. Harden worked to recruit Paul in June, with Harden spending time with the star point guard and convincing him they could be successful on the floor together.

On Saturday, Paul took to Twitter to acknowledge Harden's new contract.

CONGRATS!!!! To hell with the ball, lemme hold some 💰 pic.twitter.com/i4M1iVzCID — Chris Paul (@CP3) July 8, 2017

Harden closed the sale after Paul had a meeting with the LA Clippers two weeks ago and Paul informed the team he wanted to play for the Rockets. The Clippers and Rockets executed a trade for Paul the next day.

The Rockets followed that up with a series of trades that have allowed them to re-enter the transaction market. The Rockets have been in talks with the Knicks about Anthony, who has informed the Knicks he would waive his no-trade clause if a deal could be worked out with Houston, league sources told ESPN.

The team also landed defensive specialist PJ Tucker on a four-year, $32 million deal. Paul helped recruit Tucker to Houston as the two have been friends since their AAU days growing up in North Carolina.

Harden is coming off a career-best season in which he averaged 29.1 points, a league-best 11.2 assists and 8.1 rebounds per game.

Though Harden's annual salary under the extension could fluctuate based on the salary cap, he is expected to earn a 2019-20 salary of $37.8 million. That annual salary increases each year to $40.8 million, $43.8 million and finishes at $46.8 million in the 2022-23 season.

ESPN's Bobby Marks contributed to this report.