The Phoenix Suns traded forward T.J. Warren and the No. 32 pick in Thursday's NBA draft to the Indiana Pacers, a league source told ESPN.

The Pacers then traded the pick to the Miami Heat for three second-round picks, league sources told ESPN. The pick was used to select Stanford forward KZ Okpala.

The Pacers will send cash to the Suns, according to a league source. Phoenix wanted to unload the three years and $35 million remaining on Warren's deal to create salary-cap space.

Warren averaged 18.0 points, 4.0 rebounds and 1.5 assists in 43 games this past season, when he improved his shooting dramatically. He shot 28% from 3-point range in his first four years in the league but improved to 43% last season, the eighth-best percentage in the NBA among players with at least 100 attempts.

The trade will not be finalized until July 6, when the Pacers will have cap room to absorb Warren. Indiana will still have close to $31 million in room after the trade, with point guard Ricky Rubio a significant free-agent target for the team, sources said.

Phoenix will have $21 million in space, which would increase to $29.5 million if the Suns decline to re-sign Kelly Oubre Jr., who is a restricted free agent.

The Suns were still in rebuilding mode last season despite the talented young duo of Deandre Ayton and Devin Booker, matching Cleveland for the NBA's second-worst record at 19-63. That gave the Suns equal chance at the No. 1 overall pick this year with the Cavaliers and New York Knicks, but the ping pong balls didn't fall right for them and they ended up with the No. 6 overall pick. With that pick, the Suns selected Texas Tech's Jarrett Culver and traded him to Minnesota for power forward Dario Saric and the No. 11 pick.

ESPN's Bobby Marks and The Associated Press contributed to this report.