The Trump administration said Monday it had reached a framework agreement with China to keep TikTok operating in the United States, resolving a yearslong national-security standoff over the popular short-video app just days before a deadline that could have seen it banned.

Treasury Secretary Scott Bessent said the deal would allow TikTok's U.S. operations to continue under American-backed ownership. "President Trump played a role in this, we had a call with him last night, we had specific guidance from him we shared it with our Chinese counterparts," Bessent said in Madrid, where U.S. and Chinese officials have been holding trade talks. "Without his leadership and the leverage he provides, we would not have been able to include the deal today."

Bessent said he would not disclose details on the commercial terms but confirmed that "the commercial terms have been agreed upon." He added that negotiators had focused on ensuring the agreement "completely respects U.S. national security concerns" while allowing China "a fair investment environment in the United States."

President Donald Trump celebrated the breakthrough in a post on Truth Social, writing: "The big Trade Meeting in Europe between The United States of America, and China, has gone VERY WELL! It will be concluding shortly. A deal was also reached on a 'certain' company that young people in our Country very much wanted to save. They will be very happy! I will be speaking to President Xi on Friday."

The deal is widely expected to involve Oracle Executive Chairman Larry Ellison, a longtime Trump ally, leading a group of U.S. investors to acquire ByteDance's U.S. TikTok assets, potentially including the platform's algorithm. Oracle already hosts TikTok's U.S. data and nearly purchased the app in 2020 before the deal was blocked.

Chinese Vice Minister of Commerce Li Chenggang confirmed that both sides reached a "basic framework consensus properly resolving TikTok-related issues through cooperative means, reducing investment barriers, and promoting relevant economic and trade cooperation," according to state news agency Xinhua.

TikTok and parent company ByteDance have been under mounting pressure since Congress passed a bipartisan law banning the app unless it was sold to a U.S.-based buyer. TikTok briefly went dark on January 18 before Trump, on the eve of his second inauguration, signed an executive order delaying enforcement for 75 days. He has since granted multiple extensions, most recently to September 17.

The app, which has about 170 million U.S. users, became a political flashpoint in Washington over data privacy concerns and alleged ties to the Chinese government. Trump, who once advocated banning TikTok outright, has recently credited the platform with helping him win young voters in the 2024 election. Commerce Secretary Howard Lutnick said last week: "The president likes TikTok... but unless it's owned by Americans, and the algorithm is controlled by Americans... if we're going to have TikTok here, that's got to go."