It took two days into NBA free agency and a complicated web of maneuvers, but the Washington Wizards landed their prized point guard in Spencer Dinwiddie.

On Wednesday, the Wizards agreed to a deal to acquire Dinwiddie in a sign-and-trade agreement through a framework that included five teams, a person close to the situation confirmed.

While Washington receives Dinwiddie, the former Brooklyn Nets guard who played in only three games last season, the team sends forward Chandler Hutchison and a 2022 second-round draft pick to the San Antonio Spurs. Dinwiddie will sign a three-year deal worth $62 million.

Shortly after the transaction made the rounds on social media, Dinwiddie, 28, all but confirmed the news by tweeting a short clip from the first Harry Potter movie in which the main character discovers that he is a wizard.

In Dinwiddie, who will be entering his eighth season, Washington will have a point guard on the mend but also a younger model to pair with all-star Bradley Beal in a revamped backcourt in the wake of dealing Russell Westbrook to the Lakers.

Though Dinwiddie suffered the kind of major injury that defined the condensed 2020-21 season, in his last healthy year he averaged career highs in points (20.6), assists (6.8) and rebounds (3.5) for the Nets. It was during this 2019-20 campaign when Dinwiddie showed his scoring potential by dropping a career-best 41 points against the Spurs. Although Dinwiddie’s shooting numbers still leave something to be desired (he’s a 31.8 percent shooter from behind the three-point arc), he’s at his best driving to the basket and creating plays for others.

As a 6-foot-5 guard, Dinwiddie is an isolation specialist, and he ranked in the top 15 in the league in isolation possessions during his last healthy season. Also, Dinwiddie made more than 60 percent of his attempts at the rim. As a passer, Dinwiddie can find the open man, and 92.1 percent of his assists in 2019-20 resulted in three-pointers or interior looks, according to the tracking website PBP Stats.

The Wizards needed an all-star caliber point guard after they sent Westbrook to Los Angeles. Last season, Westbrook replaced John Wall as the franchise point guard, set the all-time league record for triple-doubles and helped carry the Wizards to a playoff berth. The one-year pairing of Westbrook and Beal appeared to produce positive results — even with a ball-dominant point guard, Beal had the second-highest scoring average in the league with 31.3 points per game.

However, the team lost in the first round of the Eastern Conference playoffs, parted ways with longtime coach Scott Brooks and soon would have to spend free agency searching for a third starting point guard in three years. According to an interview with ESPN, majority team owner Ted Leonsis said Westbrook requested the trade.

The Westbrook trade allowed the Wizards to rework their roster. In compensation for Westbrook, Washington received an elite perimeter defender in Kentavious Caldwell-Pope, as well as wing improvement with Kyle Kuzma. Also, the team added big man Montrezl Harrell, the 2019-20 sixth man of the year award winner. On draft night, Washington added backup point guard Aaron Holiday through a trade with the Indiana Pacers.