After a long and winding process that ultimately required signoffs from two U.S. federal agencies and the divestment of key assets, T-Mobile’s $26 billion merger with rival Sprint has officially won approval from the Department of Justice, which had opposed the deal until now. The decision was announced this morning by the agency’s antitrust head Makan Delrahim, potentially setting the stage for the deal to close later this year.

T-Mobile and Sprint have positioned the deal since its inception as an opportunity to create a viable third-place competitor to cellular industry leaders Verizon and AT&T, combining the third- and fourth-place carriers’ assets to achieve a similar scale. After the deal closes, the “New T-Mobile” will nearly match its historically larger rivals with a base of 100 million customers, and hold national radio spectrum capable of delivering 5G cellular service on low, mid, and high frequencies.

The Federal Communications Commission signaled its approval of the merger in May, following commitments from the companies to roll out 5G service to 97% of the U.S. population within three years while preserving its 4G price plans. But the Justice Department reportedly opposed the merger, suggesting that it would reduce competition below the top three carriers, an issue that might affect T-Mobile’s and Sprint’s budget-conscious prepaid brands Boost Mobile and Metro (formerly MetroPCS).

To make the deal viable, the DOJ insisted that the companies divest Sprint’s prepaid business, including Boost Mobile and Virgin Mobile, along with 20,000 cell sites, related spectrum, and retail stores that will enable another carrier to become a viable fourth-place national competitor. In a press release announcing the news, Sprint specified that it will give up its low-band 800MHz spectrum, which is similar to the long-reaching 600MHz spectrum T-Mobile will use to establish national 5G service.

Dish Network, a satellite TV provider that has teetered on the edge of entering the cellular market for years, agreed this week to buy those assets and seven years of access to T-Mobile’s network in exchange for $5 billion and a promise not to sell the new holdings to another company for three years. T-Mobile will also give Dish the option to take on cell site and retail leases it decommissions following the merger. Combined with Sprint’s 800MHz spectrum, Dish’s own millimeter wave spectrum holdings could enable it to offer a viable combination of slow, wide-reaching 5G and fast, location-specific 5G, akin to T-Mobile’s own strategy.

In its own press release, Dish said that it has agreed to deploy a 5G network capable of serving 70% of the U.S. population by June 2023, and that it will be acquiring 14MHz of Sprint’s nationwide 800MHz spectrum, adding to its own 600MHz, 700MHz, and 1.9GHz to 2.2GHz holdings. Notably, however, it says the 800MHz “spectrum purchase is expected to be completed three years after the closing of the acquisition of the prepaid businesses,” which suggests that it might rely heavily on T-Mobile’s network for the foreseeable future.

Dish also agreed to begin transitioning Sprint’s prepaid customers from the “Sprint legacy network” to the “New T-Mobile network,” activating all of its new wireless customers on the latter. The company expects to serve around 9.3 million customers in the U.S. and Puerto Rico, taking on 400 Sprint employees to support over 7,500 independent and company-owned retail outlets.

“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. “I want to thank our state partners for joining us in this settlement. In crafting this remedy, we are also mindful of the significant commitments T-Mobile, Sprint, and Dish have made to the Federal Communications Commission.”

Despite surviving the federal approval gauntlet, T-Mobile and Sprint still face antitrust claims from state attorneys general. Following its successful brokering of the Dish Network divestment deal, the Justice Department reportedly sought to convince a group of states to drop a lawsuit filed in mid-June to block the merger. Thirteen attorneys general representing California, the District of Columbia, New York, and other states had claimed that the deal would hurt competition and drive up cellular prices — issues that the DOJ’s antitrust review was explicitly designed to address and resolve.

As of now, five state attorneys general have signed onto the DOJ deal, which is interestingly being filed today as a second formal antitrust lawsuit against the carriers, alongside a DOJ-authorized settlement agreement that requires court approval. That agreement could conceivably win over additional states as the lawsuit moves towards court approval. For the time being, the prior state lawsuit also remains pending, and may not be resolved by year’s end: It’s currently scheduled to go to trial in October, but may be delayed until December due to today’s changes in the merger’s structure.