Ricky Rubio is getting a four-year, $56 million contract extension from the Minnesota Timberwolves.

The Timberwolves and Rubio’s agents, Dan Fegan and Jarinn Akana of Relativity Sports, have been negotiating for more than two months and had until midnight to reach a deal or Rubio would have become a restricted free agent after the season.

“We have reached an agreement and we are finalizing the paperwork now,” Akana told the Associated Press in a text message just over three hours before the deadline Friday.

Rubio is in his fourth season with the Wolves since coming over from Spain in 2011. He has yet to make an All-Star team, but has become the face of the franchise after they traded Kevin Love to the Cavaliers this summer.

Rubio averaged 10.1 points, 8.1 assists and 2.3 steals but shot just 37 percent in his first three seasons. The shooting numbers led some to say the Timberwolves would have been better off waiting to see how Rubio performs this season before extending him an offer.

WARRIORS KEEP THOMPSON — The Golden State Warriors saw no reason to wait on securing Klay Thompson’s future with the franchise.

The Warriors signed Thompson to a four-year maximum contract extension worth about $70 million, a person with knowledge of the deal said.

The person, who spoke to the AP on condition of anonymity because the team does not disclose terms, also said there is no opt-out clause for either side. The contract will keep Thompson with the team through the 2018-19 season.

The Warriors confirmed a multiyear deal with Thompson.

Thompson averaged 18.4 points, 3.1 rebounds and 2.2 assists last season, helping the Warriors reach the playoffs for the second straight year. He shot 44.4 percent from the floor and 41.7 percent from 3-point range.

BURKS TO STAY — From his second season to his third in the NBA, Alec Burks doubled his scoring and assist averages and improved his field goal percentage as well.

It’s clear that the Utah Jazz expect the improvement from the 23-year-old to keep on coming.

Burks agreed to a new four-year, $42 million contract extension that could be worth $45 million after incentives, a person with knowledge of the deal told the AP. The Jazz later confirmed the signing, but didn’t release the terms.