SAN FRANCISCO — T-Mobile US, the fourth-largest American carrier, lost thousands of customers over the last few years to rivals that offered more popular phones. But it appears to be rebounding.

The company on Thursday said it had gained 1.1 million customers, including 685,000 contract subscribers, in the last quarter. That compares with a loss of 557,000 contract subscribers, the most valuable type of customer, in the same period a year ago. The upswing was its largest customer growth in four years.

The company, based in Bellevue, Wash., started offering the iPhone in April, when it also began offering new phone plans that addressed common frustrations with wireless companies, like confusing contracts and expensive data plans.

“By fixing the things that drive them mad, like contracts and upgrades, and freeing them from the two-year sentences imposed on them by our competitors, they are choosing the new T-Mobile in unprecedented numbers,” John Legere, chief executive of T-Mobile US, said of his customers in a news release.