The Supreme Court seemed inclined on Friday to uphold a law that could effectively ban TikTok, the wildly popular app used by half of the country.

Even as several justices expressed concerns that the law was in tension with the First Amendment, a majority appeared satisfied that it was aimed not at TikTok’s speech rights but rather at its ownership, which the government says is controlled by China. The law requires the app’s parent company, ByteDance, to sell TikTok by Jan. 19. If it does not, the law requires the app to be shut down.

The government offered two rationales for the law: combating covert disinformation from China and barring it from harvesting private information about Americans. The court was divided over the first justification. But several justices seemed troubled by the possibility that China could use data culled from the app for espionage or blackmail.

“Congress and the president were concerned,” Justice Brett M. Kavanaugh said, “that China was accessing information about millions of Americans, tens of millions of Americans, including teenagers, people in their 20s.”

That data, he added, could be used “over time to develop spies, to turn people, to blackmail people, people who a generation from now will be working in the F.B.I. or the C.I.A. or in the State Department.”

Noel J. Francisco, a lawyer for TikTok, said he did not dispute those risks. But he said the government could address them by means short of effectively ordering the app to, as he put it, “go dark.”

Chief Justice John G. Roberts Jr. appeared unpersuaded.

“Are we supposed to ignore the fact that the ultimate parent is, in fact, subject to doing intelligence work for the Chinese government?” Chief Justice Roberts asked.

The court has put the case on an exceptionally fast track, and it is likely to rule by the end of next week. Its decision will be among the most consequential of the digital age, as TikTok has become a cultural phenomenon powered by a sophisticated algorithm that provides entertainment and information touching on nearly every facet of American life.

The Supreme Court has repeatedly taken up cases on the application of free speech principles to giant technology platforms, though it has stopped short of issuing definitive rulings. It has also wrestled with the application of the First Amendment to foreign speakers, ruling that they are generally without constitutional protection, at least for speech delivered abroad.

Justice Elena Kagan acknowledged that TikTok, which is an American company, has First Amendment rights. But she asked, “How are those First Amendment rights really being implicated here?”

If ByteDance divests TikTok, Justice Kagan said, the American company remains free to say whatever it likes.

Jeffrey L. Fisher, a lawyer for users of the app, said his clients should not be required to move to other platforms, using an analogy involving newspapers.

Several justices seemed to be searching for a narrow ground on which to uphold the law, and they leaned toward the government’s interest in protecting Americans’ data.