Breakups are tough. Just ask AT&T.

On Thursday the company reported a substantial $6.7 billion loss for the fourth quarter, largely stemming from the breakup fees incurred as a result of its failed acquisition of T-Mobile USA. During the same period a year earlier, the company reported a profit of $1.09 billion, or 18 cents a share. After discounting charges from the $4 billion breakup fee, AT&T’s profit was 42 cents a share, down from 55 cents a year earlier; analysts had expected 43 cents.

But the company was able to ride a wave of momentum from record iPhone sales and an influx of new subscribers, which nudged revenue up 4 percent during the quarter, to $32.5 billion from $31.4 billion a year ago. Analysts expected the company to report $31.95 billion in revenue.

Consumers showed up in droves to buy the newest version of the iPhone, the 4S, and an older model that AT&T offered to new customers free with a two-year contract. The company sold 7.6 million iPhones in the quarter, beating previous sales records. In all, AT&T sold 9.4 million smartphones.

AT&T surpassed the figures reported by Verizon, the country’s largest phone company, which said on Wednesday that it had sold 4.2 million iPhones and 7.7 million smartphones during the same period.