The US treasury secretary has said Washington reached a framework deal with China on the ownership of TikTok's American operations.

Scott Bessent said the framework was set in trade talks in Madrid to pave the way for US ownership. He added that US President Donald Trump and Chinese President Xi Jinping would complete the deal on Friday.

Trump said on Truth Social that the talks had gone very well, while China confirmed a framework agreement but said no deal would be made at the expense of Chinese companies' interests.

A deadline is looming for the Chinese owner of TikTok to find a buyer for its American operations or face a shutdown and ban in the US.

Bessent announced the framework deal on the second day of negotiations between the US and China aimed at ending a trade war.

He said the threat to shut down the social media site in the US had persuaded Chinese negotiators to drop demands for reduced tariffs as part of any deal to sell TikTok's US arm.

The agreed-upon commercial terms would protect US national security interests, he added.

US trade representative Jamieson Greer, part of the US delegation in Madrid, said the deal struck was subject to the leaders' approval, but added his team was not... in the business of having repetitive [ban] extensions.

China's top trade negotiator, Li Chenggang, said his country would not reach a deal with the US at the expense of its own principles and Chinese companies' interests. Its leadership would review any deal before it was agreed, he added.

On Monday, Bessent said the deal completely respects US national security concerns. However, some experts were sceptical over issues including who will control TikTok's powerful recommendation algorithm.

Sarah Kreps, director of the Tech Policy Institute at Cornell University, said it was unclear if the data of TikTok's American users would be fully stored and encrypted domestically, and whether independent audits would occur to detect backdoor access by Beijing.

Jim Secreto, a former national security official in the Biden administration, added that Beijing has control over whether the algorithm will be transferred to a new owner, which is probably why the TikTok deal was folded into broader trade and tariff negotiations.

If national security concerns were addressed, he said, the deal would be a major breakthrough. He noted that the data TikTok collects from Americans today could potentially enhance China's military and intelligence capabilities in the future.

In January, the US Supreme Court upheld a law banning the video-sharing app unless its parent company ByteDance sold its US division. ByteDance has insisted its US operations are independent and no data has been shared with the Chinese government, warning that the ban would violate free speech protections for its 170 million US users.

The deadline for a sale has since been extended three times, with the current extension set to end on 17 September.