The Los Angeles Lakers, long one of the NBA’s most envied and hated franchises, were teetering on the edge of new territory: pity.

Magic Johnson abruptly resigned in April as president of basketball operations and accused General Manager Rob Pelinka of backstabbing him. Coach Luke Walton was fired shortly before sexual assault allegations surfaced. Superstar forward LeBron James suffered the first major injury of his career and missed the playoffs for the first time since 2005. James’s young supporting cast battled health problems and trade rumors, crumbling after the all-star break. Owner Jeanie Buss and Pelinka struck out on their top two coaching choices to replace Walton, settling on Frank Vogel, and an ESPN investigation raised questions about the health of the organization’s work environment.

While the Lakers are commonly compared to a reality TV show, only the most depraved rubbernecks could enjoy watching a once-proud franchise fall so short of expectations and throw away a year of James’s career. For everyone else, the Lakers’ 2018-19 season was deeply sad and entirely forgettable.

After six straight draft lottery trips and amid mounting dysfunction, Pelinka’s Lakers managed to reach a trade agreement with the New Orleans Pelicans for Anthony Davis that immediately revives their title hopes. The blockbuster, league-altering deal should land like a cold splash of water to the face: No one should dream of pitying a franchise capable of falling backward into two top-five talents — James and Davis — in less than 12 months.

Of course, Pelinka received a huge assist from Rich Paul of Klutch Sports, Davis’s agent and a longtime friend of James. Paul narrowed the Pelicans’ trade options by repeatedly making it clear, including in a recent Sports Illustrated cover story, that Davis wanted to sign with the Lakers when he reached free agency in 2020.

Although the Lakers’ desperate attempt to acquire Davis before the February trade deadline failed, Paul’s stubborn patience — and the arrival of pragmatic executive David Griffin in New Orleans — rekindled talks.

Los Angeles has agreed to part with a big haul of desirable assets, including guard Lonzo Ball, forward Brandon Ingram, guard Josh Hart and three first-round picks, including the fourth pick in Thursday’s draft. The Pelicans will also have the option to swap picks with the Lakers in 2023 and 2025, according to ESPN.

Pelinka will have his hands full replacing three talented rotation players, but his efforts will be greatly aided by the presence of his superstar duo. Playing with James and Davis should be highly appealing to veteran free agents, and the Lakers still have $27 million in salary cap space to pursue a third star.

To this point of his career, James’s most memorable star partners have been perimeter players: Dwyane Wade and Kyrie Irving. Davis, a fluid big man who effortlessly racks up dunks and blocks, represents a tantalizing new challenge. James must be more willing to trust and empower Davis offensively than he was with the Miami Heat’s Chris Bosh or the Cleveland Cavaliers’ Kevin Love.

Their fit shouldn’t be much of a problem, thanks to Davis’s excellent finishing ability, soft shooting touch and perimeter range. Davis’s mobility will be key; he should feast on James’s lob passes while simultaneously spacing the court during James’s drive-and-kick forays.

Davis has twice averaged more than 28 points per game during his seven-year career, and he could conceivably lead the NBA in scoring with help from James’s elite playmaking. And by keeping Kyle Kuzma out of the trade, James will have two capable outside shooters alongside him in the frontcourt. The Lakers suddenly present all sorts of matchup problems.

Defensively, Davis is exactly the paint-controlling, rim-protecting presence that James needed last season. At 34, James is no longer a lockdown defender on a night-to-night basis. Davis’s high activity level, knack for discouraging drives and ability to alter shots will allow James to continue to focus the bulk of his energy on the offensive end.

To be clear, the benefits should run both ways in the partnership. James and Paul have already sought to raise Davis’s profile after he spent years languishing on lottery teams in small-market New Orleans. Davis, arguably the NBA’s most overlooked superstar throughout his Pelicans tenure, now moves to center stage for a glitzy large-market franchise. The days of Davis lagging in jersey sales, endorsement deals and all-stars votes are over.

Years ago, the Lakers’ ill-fated plan to have Dwight Howard follow Kobe Bryant as the face of the franchise fell apart because of major personality differences. Here, a succession plan featuring James and Davis should actually work.

The two superstars are friendly; they have appeared together on James’s HBO show “The Shop,” and James is an invested mentor, thanks in part to Paul’s presence.

Given their age difference, it’s easy to envision Davis surpassing James on the court soon. Following a listless season in which he lacked much help, James should be eager to welcome that development. After all, maximizing Davis’s potential is James’s surest path to a fourth ring.

There are still some major hurdles for Pelinka and company if the Lakers are to reach the Finals for the first time since 2010. L.A. must land a third star if possible, fill in a barren backcourt and target a traditional center to help lighten Davis’s load. The front office also must make better decisions on role players than it did with the likes of Lance Stephenson and Michael Beasley last summer.

Even so, landing Davis represents nothing short of a resurrection — for James’s golden years, for the Lakers’ credibility and relevance and for Davis’s ascent toward basketball world domination. The winding path to this trade was choppy and ugly: James and Davis spent last season in purgatory, and Johnson and former Pelicans GM Dell Demps, who was fired in February, were among the courtship’s many casualties.

Now, though, James and Davis come together at the moment the Golden State Warriors have broken down with injuries. The NBA world, in desperate need of a new central force, has found it in a predictable place: Los Angeles, capital of reinvention.

With one trade, sympathy and apathy for the Lakers immediately went out of fashion. After too many listless years, the franchise again is ready to be loved — and hated.