Sprint Corp. and T-Mobile US Inc. have agreed on the broad terms of a merger worth around $50 billion and are working toward a final agreement, people familiar with the matter said.

Under the framework, Sprint (S) would acquire T-Mobile (TMUS) for around $40 a share in a deal that could happen early this summer, the people said.

A deal could still fall through, but if completed would combine the country's third and fourth largest wireless operators, creating a bigger competitor to market leaders Verizon Communications Inc. (VZ) and AT&T Inc. (T) but leaving consumers with fewer choices for service.

A deal would face strong opposition from regulators and a lengthy antitrust review, and Sprint would pay T-Mobile more than $1 billion in cash and other assets if it is shot down, the people said.

T-Mobile's largest shareholder, Germany's Deutsche Telekom AG, would retain a stake of 15% to 20% in the new company, the people said. The deal would be worth around $50 billion including debt, the people said.

The companies are also considering forming a joint venture to bid together in upcoming auctions of wireless airwaves currently held by television broadcasters, the people said.

The sides began working with a renewed sense of urgency last month after the Federal Communications Commission voted to approve rules for a key auction of airwaves currently held by broadcasters, expected to take place in 2015. The companies both felt revisions the agency made to the auction rules would help their case for a merger, according to several people familiar with the matter.

(Dana Mattioli contributed to this article.)