Over the past five years, the Toronto Raptors have, for the first time, become a truly relevant NBA franchise. They have qualified for the playoffs each of the past five years after making the playoffs just five times in their first 18 seasons. They won one playoff series in their first 20 years of existence, then won four series in the last three years.

But by firing coach Dwane Casey in May after being swept by the Cleveland Cavaliers in the Eastern Conference semifinals, Raptors President of Basketball Operations Masai Ujiri signaled that just being good or relevant wasn’t an acceptable standard in Toronto.

By trading for Kawhi Leonard early Wednesday, Ujiri reiterated that message — loudly.

The deal — Leonard and Danny Green to Toronto for DeMar DeRozan, Jakob Poeltl and a protected first-round pick — comes with little risk for Toronto. While Leonard is only signed for this coming season, and his representatives have made it clear he wants to join the Los Angeles Lakers as a free agent next summer, giving up only DeRozan and Poeltl is about as risk-free a move as a team can make for a star of Leonard’s caliber.

Even if Leonard has no interest in spending more than a year in Canada — ESPN’s Chris Haynes tweeted early Wednesday morning that Leonard “has no interest in playing in Toronto” — this was a trade the Raptors had to make.

DeRozan is a star, but a flawed one. He struggles defensively and isn’t a threat from three-point range, complicating attempts to build around him. Those limitations are partly to blame for Toronto plateauing in the playoffs year after year. That’s why Ujiri was ready to blow up the team in the first place. Sure, if Leonard leaves it would cost the Raptors at least one year of all-star wing play (DeRozan’s final year of his deal is a player option). But giving him another contract at 30 or 31 was going to wind up being a bad deal.

The Raptors were also able to make this deal without moving either of their two highest-upside young players, OG Anunoby and Pascal Siakam, which shows just how little leverage the Spurs had. Talks between these two teams have been in the works for some time, as The Washington Post reported last week.

With the Boston Celtics showing little to no interest, the Philadelphia 76ers being unwilling to include Markelle Fultz and the Lakers showing no urgency to make a deal after LeBron James signed a four-year deal earlier this month, Toronto was the only team offering any kind of front-line talent. The price it paid reflected that.

It still hurts to trade DeRozan. He isn’t as good as Leonard, but he is a four-time all-star and the franchise’s all-time leader in games, minutes, points and field goals made. Perhaps most importantly, he gave the Raptors newfound credibility when he re-signed for five years in 2016. That a kid from Compton would pass up the chance to even meet with his hometown Lakers — who were determined to sign him to become the new face of their franchise and replace his idol, Kobe Bryant — to instead stay in a hockey town was a seminal moment for a franchise that had never before been able to secure such a commitment from a star.

In yet another layer, DeRozan’s camp had been led to believe he wouldn’t be traded as this deal has percolated in recent days, sources said. And as his Instagram story indicated early Wednesday morning — reading, “Ain’t no loyalty in this game. Sell you out quick for a little bit of nothing” — DeRozan was less than thrilled that he’d been misled.

Masai Ujiri knew that very good wasn’t good enough for his Raptors. (Nathan Denette/The Canadian Press via AP)

Ujiri clearly decided this was still a move worth making. Oklahoma City Thunder General Manager Sam Presti used the same rationale in trading for Paul George last summer — a move that was seen as a similar risk at the time, but that George proved to be a wise gamble after he chose to re-sign in Oklahoma City this summer.

Ujiri is hoping for a similar outcome, and he’s right to roll the dice.

Yes, there has been an awful lot of weirdness around Leonard over the past year. But the mysterious quad injury that dogged him all last season, limiting him to nine games and turning the typically drama-free San Antonio Spurs into a constant circus, has made some people forget the fact that, when he’s healthy, he’s one of the five best players in the NBA.

Getting a shot at a superstar is rare in the NBA. Toronto now has one.

With a healthy Leonard, new Coach Nick Nurse’s Raptors would be as deep and versatile as any team in the league, with a roster rich in length, athleticism and shooting. Green isn’t a star, but he is a solid “3-and-D” wing — something every team is seeking. He should immediately slide into Toronto’s starting lineup, and he joins a stable of wing players that can match up with any opponent.

Before this deal, Toronto clearly stood behind the Boston Celtics and Philadelphia 76ers in the pecking order in the Eastern Conference. After it? The Raptors very well may be the best team in the East next season.

San Antonio, meanwhile, finds itself without a true superstar for the first time since David Robinson was drafted 31 years ago, and in a weird middle ground as Gregg Popovich enters what many expect to be the final two years of his legendary coaching career.

By trading Leonard for this package, the Spurs should be a 50-win playoff team even in the brutal Western Conference. Remember: The Spurs won 47 games last year with Leonard playing in only nine. While San Antonio would obviously rather have Leonard, DeRozan and Poeltl represent an upgrade over last season’s talent.

In DeRozan and LaMarcus Aldridge, San Antonio has a pair of all-stars. Add in the team’s solid depth and Popovich’s coaching acumen, and the Spurs will remain a solid, mid-tier playoff team.

What the Spurs won’t be, though, is a real contender. Ironically, they have become a Western Conference version of what Toronto has been: a very good team without a realistic path to title contention. The one way that changes is if one or more of San Antonio’s young players — either Dejounte Murray or rookie Lonnie Walker IV — develops into a game-changing star in the manner Leonard did since being taken 15th in 2011. That is unlikely, to be sure — but, then again, so was Leonard becoming the player he turned into. Perhaps lightning will strike twice in San Antonio.

More likely, the Spurs will simply be a very good, though not great, team for the remainder of Popovich’s tenure. San Antonio will then have both DeRozan and Aldridge as large expiring contracts in 2021, and only have Walker’s salary currently on the books for that summer, giving the franchise a chance to completely remake its roster at that point if it so chooses.

Toronto, meanwhile, is hoping this year can take what was already the greatest stretch in franchise history and raise it another level, allowing the Raptors to go somewhere they haven’t been. If they do, and Leonard sticks around, suddenly Toronto would have a foundational star on its roster, and would be heading into 2020 with enough cap room to sign at least one other max player, and potentially two.

Don’t think Ujiri hasn’t contemplated the possibility of pairing Leonard with Anthony Davis, who is set to be a free agent that summer, or Giannis Antetokounmpo, who will be a free agent the following July. Getting Leonard gives Toronto the kind of lure for stars franchises almost always need these days (unless they are the Lakers, and LeBron James decides he wants to live in Los Angeles).

And if Leonard does leave, Toronto will remain a decent team for one season and then can wipe its books virtually clean in 2020 — the only player currently under contract is Norman Powell at $10.8 million — and Ujiri can build whatever kind of team he wants.

There’s no question it’s a gamble, but Toronto has spent five years being very good. In making this trade, Ujiri is hoping the Raptors of the next five years will be great.