From the early days of the Trump administration, Stephen Miller, the president’s chief adviser on immigration, has repeatedly tried to use an obscure law designed to protect the nation from diseases overseas as a way to tighten the borders.

The question was, which disease?

Mr. Miller pushed for invoking the president’s broad public health powers in 2019, when an outbreak of mumps spread through immigration detention facilities in six states. He tried again that year when Border Patrol stations were hit with the flu.

When vast caravans of migrants surged toward the border in 2018, Mr. Miller looked for evidence that they carried illnesses. He asked for updates on American communities that received migrants to see if new disease was spreading there.

In 2018, dozens of migrants became seriously ill in federal custody, and two under the age of 10 died within three weeks of each other. While many viewed the incidents as resulting from negligence on the part of the border authorities, Mr. Miller instead argued that they supported his argument that President Trump should use his public health powers to justify sealing the borders.

On some occasions, Mr. Miller and the president, who also embraced these ideas, were talked down by cabinet secretaries and lawyers who argued that the public health situation at the time did not provide sufficient legal basis for such a proclamation.

That changed with the arrival of the coronavirus pandemic.

Within days of the confirmation of the first case in the United States, the White House shut American land borders to nonessential travel, closing the door to almost all migrants, including children and teenagers who arrived at the border with no parent or other adult guardian. Other international travel restrictions were introduced, as well as a pause on green card processing at American consular offices, which Mr. Miller told conservative allies in a recent private phone call was only the first step in a broader plan to restrict legal immigration.

Unlock more free articles.
Create an account or log in
But what has been billed by the White House as an urgent response to the coronavirus pandemic was in large part repurposed from old draft executive orders and policy discussions that have taken place repeatedly since Mr. Trump took office and have now gained new legitimacy, three former officials who were involved in the earlier deliberations said.

One official said the ideas about invoking public health and other emergency powers had been on a “wish list” of about 50 ideas to curtail immigration that Mr. Miller crafted within the first six months of the administration.

He had come up with the proposals, the official said, by poring through not just existing immigration laws, but the entire federal code to look for provisions that would allow the president to halt the flow of migrants into the United States.

Administration officials have repeatedly said the latest measures are needed to prevent new cases of infection from entering the country.

“This is a public health order that we’re operating under right now,” Mark Morgan, the acting commissioner of Customs and Border Protection, told reporters earlier this month. “This is not about immigration. What’s transpiring right now is purely about infectious disease and public health.”

The White House declined to comment on the matter, but a senior administration official confirmed details of the past discussions.

The architect of the president’s assault on immigration and one of Mr. Trump’s closest advisers inside the White House, Mr. Miller has relentlessly pushed for tough restrictions on legal and illegal immigration, including policies that sought to separate families crossing the southwest border, force migrants seeking asylum to wait in squalid camps in Mexico and deny green cards to poor immigrants.

Mr. Miller argues that reducing immigration will protect jobs for American workers and keep communities safe from criminals. But critics accuse him of targeting nonwhite immigrants, pointing in part to leaked emails from his time before entering the White House in which he cited white nationalist websites and magazines and promoted theories popular with white nationalist groups.

The idea that immigrants carry infections into the country echoes a racist notion with a long history in the United States that associates minorities with disease.

Sign up to receive an email when we publish a new story about the coronavirus outbreak.
Sign Up
The federal law on public health that Mr. Miller has long wanted to use grants power to the surgeon general and president to block people from entering the United States when it is necessary to avert a “serious danger” posed by the presence of a communicable disease in foreign countries.

The administration in adopting the latest restrictions on immigration has relied not only on that public health authority, but also on another provision of federal law that allows the president to deny entry to foreigners whose presence “would be detrimental to the interests of the United States.”

The provision, section 212(f) of the Immigration and Nationality Act, grants broad power to the president, but sets a high legal bar for its use. The Reagan administration invoked it to block large numbers of Haitians traveling by sea to seek asylum in the United States, and during the Obama administration, it was used to enforce sanctions against Iran.