Justice Neil M. Gorsuch, confirmed to the court in 2017, seemed concerned that the law gave federal officials too much power to bring in such people even decades after they had completed sentences for what could be somewhat minor crimes.

“Is there any limit on the government’s power?” Gorsuch asked Justice Department lawyer Zachary D. Tripp.

New Justice Brett M. Kavanaugh, on the other hand, noted that might be a reason for the court not to impose a time constraint on the government.

“Congress knew it wouldn’t be immediate, and yet Congress did not put in a time limit,” Kavanaugh told Cecillia D. Wang, a lawyer for the American Civil Liberties Union, representing a class of people who had been detained.