The talks with Dish Network, Charter and Altice were reported this week by Bloomberg News.

Executives at Sprint and T-Mobile argue that the companies need to merge to compete with their bigger rivals, and to afford investments in the next generation of wireless technology, known as 5G.

The companies have tried to merge three times in the last five years. Two years ago, they failed to agree on terms. A deal announced in 2014 was abandoned when federal regulators voiced concerns that it could hurt consumers. T-Mobile, in particular, has pushed the entire industry to offer lower prices, shorter contracts terms and fewer restrictions.

The deal requires approval by both the Justice Department, which enforces antitrust law, and the Federal Communications Commission, which oversees the telecommunications industry.

Ajit Pai, the chairman of the F.C.C., signaled his support last month. He said the support was based on the companies’ commitment to invest in rural broadband service and 5G technology. The companies also committed to selling off Boost Mobile.

The states, which argued in their complaint that the merger would cost Sprint and T-Mobile subscribers at least $4.5 billion a year, intend to seek a preliminary injunction, said Xavier Becerra, the attorney general of California. If that happened, Sprint and T-Mobile would first have to resolve the lawsuit from the states, even if the Justice Department approved the deal.

But the case could run into trouble because it doesn’t take into account the selling of both Boost and the wireless frequencies to another company, analysts said.

“The states would have to evaluate whether they believe in light of that divestiture their arguments about harm are still valid,” said Blair Levin, an analyst at New Street Research. “We are in uncharted territory.”