T-Mobile won Justice Department approval for its $26 billion merger with Sprint on Friday by selling satellite TV company Dish the tools it needs to become the nation’s fourth largest cellular carrier.

T-Mobile won the nod from the DOJ’s antitrust department by selling Dish two prepaid mobile brands owned by Sprint— Boost Mobile and Virgin Mobile — as well as spectrum licenses for $5 billion.

The T-Mobile-Sprint tie-up, which would combine the country’s third- and fourth-largest cellular companies, still faces a lawsuit from 13 state attorneys general who are concerned that the marriage will raise prices for consumers, including NY AG Letitia James.

The trial is set for Oct. 7, although structural changes announced on Friday could delay it until Dec. 9.

Still, the DOJ’s approval was a major hurdle that was only overcome due to the sale of assets to Dish.

DOJ antitrust chief Makan Delrahim, who wanted a deal to create fourth carrier in place before OKing the merger, recently threatened to block the T-Mobile/Sprint marriage when talks to sell to Dish stalled.

His OK Friday sent the stock of both companies up in mid-day trading, with T-Mobile climbing 5% to $83.91 per share, and Sprint jumping 6.9% to $7.95.

“Today’s settlement will provide Dish with the assets and transitional services required to become a facilities-based mobile network operator that can provide a full range of mobile wireless services nationwide,” Delrahim said on announcing the agreement.

In addition to selling Dish the pre-paid card services and 800 MHz spectrum licenses, Dish will also get access to the T-Mobile network for seven years while building out its own 5G network.

That access will allow Dish to speed up its offerings while it spends years — and billions — building out its own network.

On Friday, the AGs said they remain committed to taking their case to court — in part because Dish will need to rely on T-Mobile’s network for years before becoming a viable fourth carrier on its own.

“We have serious concerns that cobbling together this new fourth mobile player, with the government picking winners and losers, will not address the merger’s harm to consumers, workers, and innovation,” NY AG James said.

“T-Mobile and Sprint are asking Americans to trust that this new mega corporation will act directly against its own economic interests by helping transform DISH into an independent competitor that rivals this new company,” James added.

The Federal Communications Commission already gave the T-Mobile/Sprint tie-up the thumbs up earlier this year. All the companies had to do to win that nod was to commit to investing in rural broadband development and building out a 5G infrastructure.

Delrahim tried to convince the coalition of AGs suing the block the deal to drop their suit earlier this week, the Wall Street Journal reported Thursday.

T-Mobile, based in Bellevue, Wash., overtook Sprint of Overland Park, Kan., as the nation’s third-largest carrier several years ago — thanks to colorful CEO John Legere’s campaign to slash fees and give consumers more freedom to break their carrier contracts.

The companies have agreed to not raise prices for three years if they are joined.

T-Mobile is controlled by Deutsche Telekom AG, a German corporation headquartered in Bonn, Germany, while Sprint is controlled by SoftBank Group Corp., a Japanese Corporation headquartered in Tokyo, Japan.