AT&T Inc. said it was buying T-Mobile USA from Deutsche Telekom AG for $39 billion in cash and stock, a move that would create the nation's largest wireless carrier and shift the competitive landscape of the U.S. industry.

In stitching together the second- and fourth-largest U.S. mobile carriers, AT&T is showing a fearless attitude toward...