Donald trump was on a flight back from florida in late july when he announced the us faced a new threat that needed to be banned: tiktok, the chinese-owned video app which has become hugely popular among younger americans.

Delivered to reporters on air force one, the presidents decision came as a complete surprise to the lawyers and white house aides who had been working to finalise a deal that would place tiktoks us business in the hands of microsoft, the seattle-based tech giant. we are not an m&a country, mr trump said, using a term for mergers and acquisitions.

The presidential intervention set off a frenetic two months of wrangling, intrigue and lobbying that has marked the most politicised takeover battle in recent american history and one that has still not been concluded.

Oracle, the technology group chaired by larry ellison, one of the very few senior figures in silicon valley to publicly support mr trump, has emerged this week as tiktoks preferred partner in the us. however, by friday a deal to acquire a minority stake was still awaiting approval from a reluctant white house.

The trump administration has also raised the stakes by announcing on friday morning that it would ban tiktok from apple and google app stores, a move that could erode the user experience of the app until a deal is signed.

The controversy over tiktok has crystallised the growing technological rivalry between the us and china a conflict some describe as a new cold war where the ability to collect large volumes of individual data is one of the key battlegrounds. it also has the potential to be a factor in the upcoming presidential election.

After a process in which potential risks to national security have become mingled together with personal political interests, analysts say the battle over tiktok is another example of the trump administration setting an unstable playing field for companies wishing to do business in the us.

We may even be going beyond what emerging markets do to protect economic interests, says saikat chaudhuri, executive director of wharton schools mack institute for innovation management. its really extreme and unacceptable for the leading democracy and whats supposed to be a tech leader and an example for how free markets can work.

One person close to the negotiations characterised the sale of tiktok as driven by politics and greed".

Bytedance has found itself in the crosshairs of the white house because it had accomplished something no other chinese company has ever managed: building a popular consumer app that reached deep into american households.

As of early september, tiktok had more than 53m average weekly users posting and viewing short videos on the app, according to the mobile data provider app annie, dwarfing its closest us competitors. the app is particularly popular among teenagers and so-called creators, who post videos dispensing everything from viral dance routines to life advice.

Investors have valued bytedance as high as $140bn in secondary market trades, partly reflecting the future potential of its global business.

However, by the time of mr trumps intervention in july, tiktoks parent company bytedance had already spent the best part of a year trying to keep its business in the us alive. it hired a former disney executive, kevin mayer, to lead tiktoks global operations from the us, aided by a small army of lobbyists. as the possibility of a ban grew more likely, the discussions morphed into a plan to sell tiktoks us operations to microsoft.

Yiming always knew that having an ally in the us was necessary, said one person close to the negotiations, referring to bytedance chief executive zhang yiming.

The us national security community had been keeping close tabs on tiktok since at least early 2019, according to one official, believing that the data it collects could be used for espionage. mr trump warned last month that china could use the app to build dossiers of personal information for blackmail and conduct corporate espionage.

The committee on foreign investment in the us, an inter-agency body that assesses the national security implications of foreign deals with us companies, has also gained stature during the trump presidency. theyre taking the position that they do care whether we remain the pre-eminent economic power on the world stage, says antonia tzinova, a partner at the law firm holland & knight who advises on cfius issues.

Simmering national security concerns about tiktok burst into the open in october last year after us senator marco rubio called for cfius to review the app, alleging it censored content that could anger beijing. the committee opened an investigation into bytedances 2017 acquisition of the short video app , which paved the way for tiktoks global growth.

In early discussions with cfius, bytedance thought it would be able to successfully negotiate a resolution. one proposal that gained traction would have created a technical partnership with microsoft, which would be tasked with securing the data of tiktoks us users.

The first signs of a breakdown in the talks came in june, after activist teens on tiktok appeared to derail a trump rally in tulsa, oklahoma, according to people involved in the process. weeks later, secretary of state mike pompeo said on fox news that the administration was looking at banning tiktok. tiktok had already been banned in india, following a border stand-off with china.

Soon after, bytedances investors including general atlantic and sequoia capital began holding discussions with trump officials, hoping to persuade them to accept changes to bytedances voting and organisational structure. but those proposals failed to satisfy the white house, which wanted broader changes to tiktoks shareholder structure, according to two people with knowledge of the discussions.

Thereafter, bytedance began discussing a sale of tiktoks american operations to microsoft, a plan that gained the support of the treasury. on the friday in july that mr trump announced he would ban tiktok, microsoft was optimistic it was close to achieving the treasurys approval to purchase tiktoks operations in the country, according to people involved in the discussions.

Mr trumps late-night announcement on air force one reset the discussions, sending his advisers into disarray. the president also called for the treasury to receive a payment for arranging the deal, an unprecedented manoeuvre that alarmed legal experts inside and outside of the administration.

Microsoft chief executive satya nadella reassured mr trump about the plans, and the company released a statement saying it would continue discussions to purchase tiktoks us operations, while also providing proper economic benefits to the country.

But mr trump had already adopted a hawkish stance towards tiktok, following the lead of mr pompeo and white house adviser peter navarro, who were in favour of banning the app, according to people briefed on the discussions. in an executive order, mr trump set a september 20 deadline for tiktok to be sold to a us company or be banned in the country.

When oracle announced on monday that it had won the deal for tiktok, national security analysts quickly began to question what the companies billed as a technical partnership.

For some people close to the discussions, it appeared that bytedances proposal mirrored a previous technical arrangement that had been rejected during discussions with microsoft. since then china has inserted itself into the negotiations making approval of a deal even more complicated. beijing announced new export controls in late august for the kinds of artificial intelligence algorithms employed by tiktok. as a result, bytedance concluded that any deal would need to keep the companys lucrative algorithms housed in china and to avoid the sale of a majority stake, according to one person close to the company.

Bytedance investors had encouraged oracle to get involved in the talks over tiktok in the hope of creating a competitive dynamic, according to people familiar with their thinking. bytedance executives had also started to view microsoft as inflexible and overeager to purchase tiktoks assets, including those outside of the us, according to people briefed on their thinking. one person close to microsoft said it was uncompromising on privacy and security issues.

Oracle also benefited from close ties to the trump administration that dated back to the presidents election victory. safra catz, oracles chief executive, served on mr trumps transition team in 2016, and mr ellison held a fundraiser for mr trump at his home this year.

On saturday september 12, mr ellison spoke to mr trump to reassure him that oracles proposal was in the best interests of us national security, say two people briefed about the call. days later ms catz, who has expressed support for israeli industry, was seen at the white house, where the us president was completing negotiations on a peace agreement between israel, the united arab emirates and bahrain.

Bytedances advisers have argued their proposal mirrors provisions put in place during the 2018 sale of the insurer genworth to chinas oceanside, which cfius approved. but analysts say that precedent may have little application now.

The geopolitical realities have shifted significantly since then as has the national security zeitgeist around the prudence of engaging with chinese firms in areas of potential data sensitivity, says adam lysenko, associate director at rhodium group, a new york-based advisory firm.

The trump administrations efforts to address the danger posed by tiktok are necessary and a distinct improvement over the status quo, but only if they result in a clean break from chinese control, mr rubiotold the financial times.

By friday morning, mr trump was still on the fence about whether to approve or block the deal, say people with direct knowledge of the matter. one person involved in the talks with the white house said the president was seeking ways to salvage the deal by diluting the ownership stake of bytedance, a move that would avoid banning the app completely. bytedance, meanwhile, is aiming to list tiktok on a us exchange in about a year if its deal with oracle is approved.

However, the white house is also concerned about the political fallout from the tiktok battle. mr trump is worried that by banning the app, he risks galvanising younger democrat voters to mobilise against him in the november election, says one person who was discussing the terms with the white house.

On the flipside, mr trump is also worried that approving a deal where bytedance retains a majority stake in tiktok could make him look weak on china, the person added.

For chinese companies, though, tiktoks saga has already set a concerning precedent. it will weigh especially on technology firms trying to scale in the us, says mr lysenko. if alibaba or tencent ever had ambitions to grow alipay or wechat pay here, this should completely dash those expectations.