WASHINGTON >> The Supreme Court upheld a law Friday that effectively bans the wildly popular app TikTok in the United States starting Sunday, rejecting the company’s First Amendment challenge.

The unanimous decision landed days before the ban is to take effect if TikTok is not divested from its Chinese parent, ByteDance, thrusting the future of the app into doubt and raising the possibility of a death blow to its U.S. operations. President-elect Donald Trump, who has vowed to “save” the app, is to be inaugurated a day later.

In ruling against TikTok, the court acknowledged the wide-ranging cultural impact of the app while siding with the government’s concerns that its Chinese ownership posed national security concerns.

“There is no doubt that, for more than 170 million Americans, TikTok offers a distinctive and expansive outlet for expression, means of engagement, and source of community,” the court’s opinion said. “But Congress has determined that divestiture is necessary to address its well-supported national security concerns regarding TikTok’s data collection practices and relationship with a foreign adversary.”

TikTok gained a foothold in American culture in 2020 as a pandemic curiosity and swiftly grew into an undeniable juggernaut. It serves up short-form videos that are a leading source of information and entertainment to tens of millions of Americans, especially younger ones.

Not only has the app given rise to a new crop of celebrities and fueled chart-topping books, music and movies, but it has also helped shape conversation around the Israel-Hamas war and last year’s U.S. presidential election.

Although TikTok’s lawyer told the justices last week that the app would “go dark” if it lost the case, it was not clear how quickly a shutdown would play out. At a minimum, app store operators like Apple and Google face significant penalties imposed by the law if they continue to distribute and update the TikTok app.

In accepting the government’s arguments that China’s control of TikTok’s corporate parent poses a threat to the nation’s security, the court ruled that Congress was entitled to put to its owners the choice between selling it or an effective ban.

The decision, delivered on an exceptionally abbreviated schedule, has few rivals in the annals of important First Amendment precedents and in the vast practical impact it will have. But the opinion stressed that some of its conclusions were tentative.

“We are conscious,” it said, “that the cases before us involve new technologies with transformative capabilities. This challenging new context counsels caution on our part.”

Justices Sonia Sotomayor and Neil Gorsuch issued concurring opinions that agreed with the majority’s bottom line but questioned some of its reasoning.

The government had offered two justifications for the law: that China’s control of TikTok allowed it to harvest troves of private data and to spread covert disinformation. The court accepted only the first rationale, saying that TikTok’s ownership structure gave rise to distinctive and troubling concerns.

“Data collection and analysis is a common practice in this digital age,” the majority opinion said. “But TikTok’s scale and susceptibility to foreign adversary control, together with the vast swaths of sensitive data the platform collects, justify differential treatment to address the government’s national security concerns.”

The decision landed days before Trump is to take office. The president-elect has signaled his support for the app and is exploring the possibility of an executive order that could allow TikTok to keep operating despite the pending ban.

But the challenged law gives him limited room to maneuver, as it allows the president to suspend the law for 90 days only if he certifies to Congress that there has been significant progress toward a sale documented in “relevant binding legal agreements.”

Trump has other alternatives. He could instruct the Justice Department not to enforce the law for now. He could urge Congress, now controlled by Republicans, to enact new legislation. Or he could try to persuade ByteDance to comply with the law — by selling TikTok.

“The Supreme Court decision was expected, and everyone must respect it,” Trump wrote on social media. “My decision on TikTok will be made in the not too distant future, but I must have time to review the situation. Stay tuned!”

Even as the Biden administration has indicated that the timing of the decision left it to the incoming administration to enforce the law, Attorney General Merrick Garland welcomed the ruling.

“Authoritarian regimes should not have unfettered access to millions of Americans’ sensitive data,” he said in a statement. “The court’s decision affirms that this act protects the national security of the United States in a manner that is consistent with the Constitution.”

People who create videos posted on TikTok, on the other hand, said the decision was a stinging financial blow.

“It’s a big source of the way that I make my living,” said Riri Bichri, of her 2000s nostalgia parody videos. “Everyone will have to adapt.”