The US Justice Department has agreed to a settlement with Disney that will allow it to purchase most of 21st Century Fox's assets.

As part of the settlement, Disney will have to sell off 22 of Fox's regional sports networks.

Disney's purchase isn't yet final. The settlement must first be approved by a federal judge, and Fox's shareholders also have to vote in favor of the deal.

Disney said in a statement that it is pleased to resolve the Justice Department's "limited potential concerns." The company had earlier said in proxy filings that it would sell the sports networks if required by the government.

Disney first reached an agreement last December to buy most of Fox's TV and movie assets. The company sweetened its offer earlier this month after Comcast tried to gatecrash the deal.

Comcast (CMCSA) has not said publicly whether it will try to counter again. Comcast did not immediately respond to a request for comment Wednesday.

Last week, Fox said it would still consider bids from other companies, even though it believed Disney's new offer was better than Comcast's.

21st Century Fox is the next big prize as the media industry consolidates to survive against competitors such as Netflix and Facebook.

If Disney (DIS) closes the deal, it will get Fox's movie studio along with cable channels like FX and National Geographic. Disney would also get Fox's stake in the streaming service Hulu, along with its stake in the European broadcaster Sky.

The government approved the Disney deal with Fox about six months after the merger was announced, a relatively quick timeline for the large size of the transaction.

Wednesday's news comes about two weeks after the Justice Department lost its attempt in court to stop AT&T from buying CNN parent company Time Warner.

Antitrust regulators challenged that deal because they said it would harm competition and raise prices for consumers.

In Disney's case, officials said their concerns about the deal would be alleviated as long as Disney sold the regional sports networks.

"American consumers have benefitted from head-to-head competition between Disney and Fox's cable sports programming that ultimately has prevented cable television subscription prices from rising even higher," said Assistant Attorney General Makan Delrahim of the Justice Department's Antitrust Division. "Today's settlement will ensure that sports programming competition is preserved in the local markets where Disney and Fox compete for cable and satellite distribution."