Stephen Yang/Bloomberg News

AT&T on Monday ended its effort to buy T-Mobile USA, acknowledging that it could not overcome stiff opposition by the Obama administration to form the nation’s biggest cellphone service provider.

The decision to scrap the $39 billion takeover — which would have been the biggest deal of the year — is a major setback for AT&T, which had pinned its hopes for growth on the acquisition. The company wanted T-Mobile’s cellular airwaves, or spectrum, to relieve its congested network and offer faster service for data-hungry devices like the iPhone.

And the deal’s end leaves T-Mobile, the weakest of the four national operators, with an uncertain future.

For the Obama administration, the collapse of the deal is confirmation that it has reinvigorated antitrust oversight that it said had become weak under its predecessor. The Justice Department took the aggressive step of suing to block the deal in late August, while the Federal Communications Commission had signaled its intent to fight the merger as well.

“People in this town didn’t think that the department was willing to take the risk to litigate big, complex cases,” said a senior Justice Department official, who spoke on the condition of anonymity because employees were not authorized to go beyond the department’s public statement. “But this puts down a very firm marker that we are taking antitrust enforcement very seriously.”

The company had sought to offer concessions to win regulatory approval, including potentially selling more than a quarter of T-Mobile’s customers and spectrum to a competitor like Leap Wireless.

Other ideas included possible network-sharing agreements, though those were less fully developed.

After the F.C.C. declared its opposition to the deal, AT&T withdrew its application for approval from the agency on Thanksgiving. Last week, AT&T asked for a delay in the Justice Department lawsuit as it weighed its options.

By this last weekend, AT&T had concluded that no change to its bid would have been enough to pass muster, according to people briefed on the matter.

A merger of the two companies, consumer advocates had said, would have created a duopoly of AT&T and Verizon Wireless with almost three-quarters of the market between them.

“Consumers won today,” Sharis A. Pozen, the Justice Department’s acting assistant attorney general for antitrust, said in a statement. “Had AT&T acquired T-Mobile, consumers in the wireless marketplace would have faced higher prices and reduced innovation.”

AT&T will pay Deutsche Telekom $4 billion in cash and wireless spectrum access as a break-up fee under the terms of the merger announced in March. After taxes, however, the financial hit to AT&T will be only about $1.5 billion, or roughly two months’ worth of cash flow. The two companies will now begin a seven-year roaming agreement that will expand T-Mobile’s national coverage.

That agreement, however, does not solve AT&T’s network constraints. Nor does it shore up T-Mobile’s diminishing competitive position. Deutsche Telekom has indicated that it would like to dispose of T-Mobile eventually, having failed to develop it into a stronger competitor to AT&T, Verizon Wireless and Sprint Nextel.

The push for a merger was spearheaded by Randall L. Stephenson, AT&T’s chairman and chief executive, in his first bold strategic step since taking the reins in 2007.

To support the deal, AT&T lined up an assortment of lawmakers, corporate customers and local partners to promote the benefits of the merger.

But that campaign held little sway over government regulators, who were skeptical of arguments that uniting two of the nation’s biggest wireless companies would not harm competition. The Justice Department joined with several state attorneys general in its antitrust lawsuit and hired prominent outside counsel. And the F.C.C. published its staff’s 157-page internal report laying out its concerns about the deal.

AT&T had prepared for battle with the government, adopting at times an openly hostile stance toward the F.C.C. And few people thought the Justice Department would be able to fend off AT&T, whose Washington lobbying operation is legendary.

Still, the companies said from the beginning that they were willing to consider conditions that might be required to allow the deal to proceed. And the Justice Department had taken criticism for approving other big deals, including Comcast’s takeover of NBCUniversal.

In the case of AT&T, Justice Department officials repeatedly signaled that they would oppose the deal, and finally sued the company in late summer.

On Monday, AT&T said it would continue to invest in expanding its network. But Mr. Stephenson warned lawmakers that they must take action to increase the availability of wireless spectrum to help expand faster cellular data coverage.

“The mobile Internet is a dynamic industry that can be a critical driver in restoring American economic growth and job creation, but only if companies are allowed to react quickly to customer needs and market forces,” he said.

Analysts said that Deutsche Telekom must weigh the future of T-Mobile, including a potential sale of assets or an initial public offering.

One potential partner is Dish Network, the satellite TV provider. Its chief executive, Joseph Clayton , told Bloomberg News last week that his company was willing to pool its wireless holdings with T-Mobile’s to create a stronger competitor to AT&T and Verizon.

“T-Mobile is probably going to be profoundly damaged by this,” Tero Kuittinen, an independent research analyst, said. “They should have done some strategic rethinking instead of chasing this mirage, this dream of a merger. Now they’ve lost a lot of time.”

Edward Wyatt and Brian X. Chen contributed reporting.