The Miami Heat agreed to acquire star guard Victor Oladipo from the Houston Rockets just before Thursday’s trade deadline, a source told ESPN’s Adrian Wojnarowski.

Although sources told ESPN earlier this week that there was widespread confidence Houston would trade Oladipo, the teams went right up to the 3 p.m. ET deadline before agreeing to the trade.

In return, the Rockets get Avery Bradley, Kelly Olynyk and 2022 first-round swap rights, sources told ESPN’s Tim MacMahon. Those swap rights include Brooklyn’s pick, a source told ESPN.

With Oladipo in Miami, the Heat also are expected to emerge as a front-runner to sign LaMarcus Aldridge once the veteran big man completes a buyout with the San Antonio Spurs, sources told Wojnarowski.

Aldridge plans to talk with several teams before finalizing a decision, according to Wojnarowski.

Oladipo, 28, is in the final season of a four-year, $85 million contract and can become a free agent this summer. He ruptured his quad in January 2019, but he has shown flashes of his old self in performances with Indiana and Houston this season. Oladipo has averaged 21.2 points in 20 games with the Rockets, although his efficiency has been suboptimal.

He arrived in Houston as part of a four-team trade that delivered All-NBA guard James Harden to the Brooklyn Nets. The Rockets offered Oladipo a two-year, $45 million contract — the maximum offer that they were available to make during the season under the collective bargaining agreement — but Oladipo declined it, sources said.

Oladipo has averaged 20.8 points, 5.0 rebounds and 4.7 assists with the Rockets this season. For his nine-year career, including stops with the Orlando Magic, the Oklahoma City Thunder and the Pacers, he has averaged 17.6 points, 4.6 rebounds and 4.0 assists.

The two-time All-Star selection also has been a top defender, being named to the All-Defensive First Team in 2018, when he led the NBA in steals and also was named the league’s Most Improved Player.

The Rockets, who lost to Charlotte on Wednesday after ending a 20-game losing streak Monday night, are in a mode of gathering young players and pick assets as they move toward a rebuild.

An eight-year veteran, Olynyk is averaging 10.0 points and 6.1 rebounds for the Heat this season. He spent his first four seasons with the Celtics and has career averages of 9.7 points and 4.9 rebounds.

Bradley, a first-round pick by the Celtics in 2019, is averaging 8.5 points this season. He has also played for the Pistons, Clippers, Grizzlies and Lakers during his career and is averaging 11.7 points and 2.9 rebounds over 11 seasons.

The Kansas City Chiefs are 2019 NFC Champs - get your gear on at Fanatics