Deutsche Telekom?s announcement over the weekend to sell its American wireless unit, T-Mobile USA, to AT&T for $39 billion ended a decade-long foray into the American market that was undermined, in part, by one big event: the advent of the iPhone.

Until Apple introduced its highly popular touchscreen device in 2007, which went on to become the world?s leading smartphone, Deutsche Telekom had been generating decent sales from its American operation, with growth in some years surpassing that achieved in Germany.

But after the iPhone went on sale, sold exclusively at first by AT&T in the US, T-Mobile USA began to lose its most lucrative customers, those on fixed monthly plans, who defected to its larger American rivals ? AT&T and Verizon Wireless, which began selling the iPhone in February.

The percentage of T-Mobile USA?s contract customers fell to 78.3% in 2010 from 85% in 2006, as per the company?s annual reports. During 2010 alone, T-Mobile USA lost 390,000 contract customers to rivals.

The sale of the American unit by Deutsche Telekom, which is based in Bonn, was welcomed by investors, and the company?s stock was up more than 12% in late trading Monday in Frankfurt.

Under terms of the deal, Deutsche Telekom will receive $25 billion in cash from AT&T and $14 billion in stock, representing an 8% stake in the AT&T.