DeAndre Jordan intends to sign with the Los Angeles Lakers upon completion of a buyout with the Detroit Pistons, sources told ESPN on Friday.

Jordan was traded by the Brooklyn Nets to the Pistons earlier Friday along with four second-round picks and $5.78 million for Jahlil Okafor and Sekou Doumbouya, sources said.

An All-Star in 2017, Jordan has two years and $20 million left on the four-year, $40 million contract he signed in June 2019. He would have to first clear waivers to become a free agent.

The trade allows the Nets to save $47 million in salary and luxury tax. They will send the Pistons their 2022 and 2027 second-round picks along with the more favorable 2024 second-rounder between the Washington Wizards and Memphis Grizzlies and the more favorable 2025 second-rounder between the Wizards and Golden State Warriors, sources said.

Trading Jordan’s contract instead of buying it out offers the Nets financial relief in the short term, but also in the future with the repeater tax penalty starting in 2023.

Brooklyn had the option of waiving and stretching the $19.7 million owed on Jordan’s deal over five seasons; that would’ve represented a $3.9 million cap hit that would’ve lingered on the team’s books from 2021 to 2025. The move could have saved the Nets money on their luxury tax bill for the next two years but cost them an extra $20 million in 2023-24, and could’ve reached $50 million in 2024-25 and 2025-26.

The Nets are also bringing back LaMarcus Aldridge after he was cleared of the heart concerns that led him to retire in April.

It is not immediately clear whether the Nets will keep Okafor or Doumbouya or decide to waive them, sources said. That is expected to determined in the coming days and weeks. The Nets are planning to waive forward Alize Johnson, sources said.

Jordan was part of the Nets’ free-agent class in 2019 that included Kevin Durant and Kyrie Irving. Initially, Jordan alternated starting at center with Jarrett Allen, who was eventually traded to the Cleveland Cavaliers as part of the four-team deal that landed the Nets All-NBA guard James Harden. Once the Nets acquired Blake Griffin, Jordan’s role diminished.

The 33-year-old Jordan averaged 7.5 points and 7.5 rebounds in 57 games last season in Brooklyn.

Okafor, 25, averaged 5.4 points and 2.4 rebounds in 27 games last season, missing more than two months after undergoing left knee surgery. Doumbouya, 20, averaged 5.1 points and 2.6 rebounds in 56 games.

ESPN’s Malika Andrews and Bobby Marks contributed to this report.