CLEVELAND (AP) — Kyrie Irving was tired of being teammates with LeBron James.
Now he has to figure out how to beat him.
Cleveland’s All-Star guard, who asked owner Dan Gilbert to trade him earlier this summer, was dealt Tuesday night to the Boston Celtics for fellow All-Star Isaiah Thomas, forward Jae Crowder, center Ante Zizic and the Brooklyn Nets’ unprotected 2018 first-round draft pick.
‘‘It’s extremely rare to trade for a 25-year-old player that’s done what he’s done, the offensive weapon that he is,’’ Celtics president Danny Ainge said. ‘‘We feel like his best basketball is still ahead of him.
‘‘We have a player that’s proven to be a sure thing. We know how unpredictable the draft can be. You do pay a heavy price for a player of that age and that caliber.’’
Irving, whose late 3-pointer helped Cleveland win the 2016 NBA championship — and the city’s first title since 1964 — is on his way to Boston, where he’ll join a Celtics team that lost to the Cavs in last season’s conference finals.
And as fate will have it, the Cavs will host the Celtics in their season opener on Oct. 17.
‘‘Of course we know who our competition is, and we know who are biggest threats are each year,’’ Ainge said. ‘‘But we feel like this is a trade that can make us better, and that’s why we did it.’’
The blockbuster deal caps a wild summer for the Cavs, who lost their title defense in five games to Golden State in June. Since then, general manager David Griffin left, the team failed to convince Chauncey Billups to join its front office and James has played with fans’ emotions with veiled postings on social media about his future.
Irving’s trade demand cast a shadow over the entire organization.
But Cleveland may have salvaged its offseason.
‘‘This trade needed to include both players and assets that we felt strongly could help us continue to compete for championships and we believe it does,’’ said new general manager Koby Altman, who pulled off a deal that protects Cleveland’s present and future.
In Thomas, they’re getting a proven playmaker with a stellar reputation. The 5-foot-9 guard is one of the league’s most dynamic backcourt players with an uncanny ability to get to the basket. Irving may be the only better finisher among point guards.
The 28-year-old Thomas was taken with the final selection in the 2011 draft — 59 picks after Irving was picked first overall. But he has steadily scaled his way up to elite status.
Thomas’ reputation in Boston was cemented when he led the Celtics through the playoffs last season despite the death of his sister on the eve of the postseason. He also had a front tooth knocked out during the second-round series against Washington and a hip injury eventually forced the team to shut him down early in the East finals, won by the Cavaliers in five games.
‘‘Isaiah had just an amazing season this year and entertained us all, the whole city of Boston. And everybody fell in love with him,’’ Ainge said. ‘‘He’s such an underdog because of his size and his heart and his spirit which he plays.’’
Thomas is eligible for free agency next summer and believes he is worthy of a maximum contract. He has been quoted saying, ‘‘They better bring out the Brinks truck.’’
Cleveland also is getting Crowder, a solid perimeter defender, and a first-round pick that Boston got from Brooklyn. The package could help the Cavs reload if James opts out of his contract next summer and leaves Cleveland for a second time.
The Cavs drafted Irving with the No. 1 overall pick in 2011. He struggled in his first few seasons but blossomed in recent years alongside James. However, that didn’t seem to be enough for the 25-year-old, who has wanted to be the focal point on his own team.
James wished Irving well on Twitter, calling him a ‘‘special talent/guy.’’
‘‘Nothing but respect and what a ride it was our 3 years together,’’ James wrote.
Asked about trading a fan favorite who rose from the depths of the draft for a player who asked out of a team with the NBA’s best player, one year removed from a championship, Ainge said he has done his homework.
‘‘We feel comfortable with who Kyrie is and who he can be,’’ he said.
Minnesota showed some interest in Irving after his trade request became public, but were unwilling to part with young star Andrew Wiggins as the centerpiece of a deal. Wiggins is expected to sign a max contract extension in the coming weeks to stay with the Timberwolves.
The Phoenix Suns reportedly were not interested in parting with rookie Josh Jackson in a deal that also would have required Eric Bledsoe and the New York Knicks gave no indication that Kristaps Porzingis was ever on the table in a potential Irving trade.
Then the Celtics swooped in, landing the kind of star Ainge has long coveted. With the possibility of having to break the bank to retain Thomas next summer, Boston finally tapped into the treasure trove of assets that Ainge has assembled to get Irving, who is under contract for two more years.
Irving got his wish to get away from James, but he’s not free of him yet.
AP Sports Writers Jimmy Golen in Boston and Jon Krawczynski in Minneapolis contributed to this report.
More AP NBA: https://apnews.com/tag/NBAbasketball