TikTok said it filed a federal lawsuit Tuesday challenging the constitutionality of a new law that requires a sale or ban of the popular social-media app, setting up a court showdown over national security and free speech in the age of global information wars.

The suit, filed directly with a federal appeals court in Washington, D.C., seeks a court order preventing the U.S. from enforcing the bipartisan law signed by President Biden last month. The measure bans TikTok in the U.S. unless its parent company, Beijing-based ByteDance, divests itself of the platform by mid-January.

ByteDance has said it can’t and won’t sell its U.S. operations by the deadline, leaving litigation as its best hope to maintain its U.S. market. The lawsuit accuses the government of trampling on TikTok’s First Amendment rights—as well as the free-speech rights of millions of Americans—under the banner of national security.

“There is no question: the Act will force a shutdown of TikTok by January 19, 2025,” the lawsuit states, “silencing the 170 million Americans who use the platform to communicate in ways that cannot be replicated elsewhere.”

The suit also alleges the U.S. ban is an unconstitutional legislative punishment of TikTok, denies the company equal protection under the law and amounts to an unlawful taking of private property.

TikTok’s short-form video platform has quickly gained mass appeal as an entertainment platform, news source, cultural tastemaker and activist hub.

National-security officials and federal lawmakers watched its growth with alarm. Supporters of the law say TikTok offers a foreign adversary a potent tool to spy on Americans and manipulate public opinion through its algorithms. Forcing TikTok to cut ties with China is the only effective way to deal with the security risks, they say.

TikTok says it has taken measures to safeguard user data and prevent Chinese government influence.

The U.S. has long restricted foreign ownership of radio and television broadcasting, but Congress has never taken such drastic actions against an internet platform used by millions of Americans.

Courts have struck down past government restrictions on TikTok, but left the First Amendment issues unsettled.

A federal judge in Washington, D.C. ruled against Commerce Department efforts to ban TikTok during the Trump administration, deciding the agency exceeded its authority under a law from the 1970s called the International Emergency Economic Powers Act.

In a separate Pennsylvania case, another U.S. district judge, citing similar legal grounds, sided with a group of TikTok stars that sued the Trump administration with the company’s support.

Write to Jacob Gershman at [email protected]