Monday's announcement came as little surprise after the Justice Department sued to block the merger on Aug. 31. The deal looked further in jeopardy when the Federal Communications Commission's chairman also came out against it. The companies withdrew their FCC application last month.
Bernstein analyst Craig Moffett said the announcement was "a bit of an anticlimax."
"This is like receiving the divorce papers for a couple that's been separated for years," he said.
AT&T's purchase of T-Mobile from Deutsche Telekom of Germany, announced in March, would have made it the largest cellphone company in the U.S. T-Mobile is currently the fourth-largest.
AT&T, the nation's second-largest wireless carrier behind Verizon Wireless , will now have to pay Deutsche Telekom $3 billion in cash as a breakup fee and give it about $1 billion worth of airwaves, known as spectrum, that AT&T doesn't need for the continued rollout of its high-speed "4G" network.
It will also enter into a roaming agreement with Deutsche Telekom so that AT&T's and T-Mobile's customers can use each other's networks.
AT&T will book the $4 billion charge to its earnings in the fourth quarter.
In pulling out, AT&T said the government's attempts to block the deal do not change the challenges of the wireless phone industry, which has been clamoring for more airwaves to expand.
The company said the deal would have solved that problem for a time, and without it, "customers will be harmed and needed investment will be stifled." It called on the government to quickly approve its purchase of unused spectrum from Qualcomm (QCOM) and come up with legislation to meet the nation's long-term needs.
Many people, however, believe that AT&T had overstated the spectrum crisis.
AT&T Inc. already has an ample supply of unused wireless spectrum that it plans to use to expand its network over the next several years. And much of T-Mobile's spectrum is already in use, so the deal wouldn't have resulted in fresh airwaves becoming available. Furthermore, AT&T has made great strides in addressing network congestion in such cities as New York and San Francisco not by tapping its unused spectrum, but by upgrading its cell-tower equipment.
Moffett said AT&T's spectrum needs are not so grave that it needs to make a large acquisition right away.
AT&T could acquire airwave space through a possible spectrum auction through the FCC or by buying spectrum from satellite cable operator Dish Network Corp. (DISH), which could require an FCC waiver.
The decision to end the bid could be a bigger problem for T-Mobile than for AT&T. Deutsche Telekom has been eager to sell T-Mobile and isn't keen on investing more in the company, which has seen revenue decline slowly with the flight of higher-profit contract customers.
Still, Moffett believes it's too soon to write off T-Mobile, saying it has a good network with lots of room for more customers.
"I think they could surprise some people and be a more important force in the market than people are giving them credit for," he said.
AT&T's stock fell 20 cents to $28.54 in after-hours trading Monday after closing the regular session down 11 cents.
Metz reported from San Francisco.