(Recasts with own sourcing)

WASHINGTON, July 18 (Reuters) - The U.S. Justice Department has told T-Mobile US Inc and Sprint Corp to wrap up a deal by the end of next week to sell assets that are to be divested as a condition of their proposed merger or face a lawsuit aimed at stopping the transaction, a source familiar with the deal said on Thursday.

T-Mobile and Sprint did not immediately respond to Reuters' requests for comment. The Justice Department declined to comment.

CNBC was the first to report the ultimatum.

In June, a group of U.S. state attorneys general filed a lawsuit in federal court in New York to block the merger of the third and fourth largest U.S. wireless carriers, arguing that the proposed $26 billion deal would cost consumers more than $4.5 billion annually.

To win over the Justice Department, which is not involved in the lawsuit, T-Mobile and Sprint have agreed to a series of deal concessions, including selling the prepaid brand Boost.

The companies have been in talks for weeks to sell Boost to Dish Network Corp but are haggling over issues such as restrictions over who can buy the divested assets if they are sold in the future. T-Mobile and Deutsche Telekom, which owns 63 percent of T-Mobile, are seeking to prevent them from going to a cable or technology company.

Sprint is controlled by Softbank Group Corp.

The companies told the court in late June that they were willing to refrain from closing the deal until after the state attorneys general case is completed.

The two companies have a July 29 deadline to complete the deal but are expected to extend it.

Federal Communications Commission Chairman Ajit Pai has given his blessing to the merger in principle and is expected to circulate a formal order within weeks. (Reporting by David Shepardson and Diane Bartz in Washington and Akanksha Rana in Bengaluru Editing by Sonya Hepinstall and Leslie Adler)