President Donald Trump signed a presidential proclamation on Friday that will bar migrants who illegally cross the U.S. border with Mexico from seeking the right of asylum, implementing a midterm election campaign promise to bar safe haven to tens of thousands of immigrants fleeing persecution, violence and death in their homelands.

The proclamation, signed by Trump on Friday morning, declares that “aliens who enter the United States unlawfully through the southern border… will be ineligible to be granted asylum.” Only migrants who “properly present themselves for inspection at a port of entry,” the proclamation stipulates, may avail themselves of America’s asylum protections.

Two knowledgeable sources told The Daily Beast that the proclamation was authored by Trump’s senior policy adviser, Stephen Miller, the brains behind each draft of Trump’s three attempted travel bans, which sought to prevent nationals of six majority-Muslim countries from entering the United States.

One of the two sources briefed on the drafting said Miller worked closely with U.S. Department of Homeland Security Secretary Kirstjen Nielsen, to avoid a repeat of the Muslim ban fiasco which was challenged in court and had to be redrafted. The sources spoke anonymously because they were not authorized to comment on White House deliberations publicly.

Miller and the White House press office did not respond to requests for comment.

The proclamation, which was first hinted at in a meandering speech by the president days before Tuesday’s midterm elections, faced an almost immediate legal challenge the American Civil Liberties Union, the Southern Poverty Law Center, and the Center for Constitutional Rights, which jointly filed a lawsuit mere hours after the proclamation was announced. The suit, which seeks immediate injunctive relief against the proclamation’s implementation, deems the proclamation “in direct violation of Congress’s clear command that manner of entry cannot constitute a categorical asylum bar.”

“President Trump’s new asylum ban is illegal,” said Omar Jadwat, director of the ACLU’s Immigrants’ Rights Project. “Neither the president nor his cabinet secretaries can override the clear commands of U.S. law, but that’s exactly what they’re trying to do. This action undermines the rule of law and is a great moral failure.”

Civil rights groups and immigration nonprofits told The Daily Beast that the president’s proclamation amounts to an abrogation of international treaties, as well as a violation of federal law.

“This proclamation is a violation of international human rights law and an abdication of our responsibility to protect vulnerable persons,” said Michelle Brané, director of the Migrant Rights and Justice program at the Women’s Refugee Commission. “Seeking asylum is a legal right. Seeking safety is a human right.”

“ Those who enter the country between ports of entry are knowingly and voluntarily breaking the law—it’s a federal crime. ” — Senior administration official said in a conference call with reporters

Less than 24 hours before the proclamation was signed, senior Trump administration officials told reporters that the Department of Justice and the Department of Homeland Security were issuing joint rules affirming that any immigrant who entered the United States in contravention to the president’s then-undefined proclamation “will be rendered ineligible for asylum.”

“Those who enter the country between ports of entry are knowingly and voluntarily breaking the law—it’s a federal crime,” one senior administration official said in a conference call with reporters. “While immigration laws do afford people various forms of protection, the reality is that it’s a violation of federal law in the manner that these illegal aliens are entering the country.”

The forcible return of asylum-seekers to countries where they face persecution, torture or death—called refoulement—is illegal under both federal and international laws. The Immigration and Nationality Act stipulates that “any alien who is physically present in the United States, or who arrives in the United States (whether or not at a designated port of arrival…), irrespective of such alien’s status, may apply for asylum.”

Attempting to undermine the principle of non-refoulement, immigration experts said, is blatantly illegal, whether it’s done by proclamation or not.

“U.S. law specifically allows individuals to apply for asylum whether or not they are at a port of entry,” said Jadwat. “It is illegal to circumvent that by agency or presidential decree.”

Under federal law, a would-be asylee may apply for asylum at any time, including after being detained and charged with illegal entry.

Speaking with reporters ahead of the proclamation signing, a senior Trump administration official pointed reporters to the Supreme Court’s ruling in Trump v. Hawaii, the case that adjudicated the constitutionality of Miller’s third attempt at a travel ban, in which five conservative justices ruled that banning entry to the United States by a certain class of immigrants is “squarely within the scope of presidential authority.”

“ U.S. law specifically allows individuals to apply for asylum whether or not they are at a port of entry. It is illegal to circumvent that by agency or presidential decree. ” — Omar Jadwat, director of the ACLU’s Immigrants’ Rights Project

The proclamation signed on Friday states that the prohibition of extending the right of asylum to those who don’t enter the United States at one of 48 legal border crossings along the Southwestern border will be up for renewal in 90 days. In the meantime, Trump said that he will direct additional resources to “support our ports of entry at the southern border to assist in processing those aliens... as efficiently as possible.”

The Daily Beast has reported that some asylum-seekers, warned of Trump’s looming proclamation, have taken to sleeping on bridges near ports of entry at the Texas border after being turned away, allegedly because the legal crossings are understaffed.

“The government is issuing this rule while at the same time routinely denying asylum seekers access to the United States at ports of entry,” said Melanie Nezer, senior vice president of public affairs at HIAS, a Jewish a non-profit that has helped settle refugees in the United States for nearly 140 years. “The U.S. has the capacity and a moral obligation to consider the claims of those arriving at our border... these individuals deserve to be treated with dignity and respect, and should have their claims heard.”

Even if those ports receive the resources necessary to process tens of of thousands of asylum applications per month, advocates said, the proclamation denies the right of due process to those who need it most desperately.

The administration’s actions, Brané said, “will render women, children, families, and others fleeing violence more vulnerable to those who would prey upon them. It will put desperate people at even greater risk of being returned to the dangers they were forced to escape from in the first place. And it will show the world, once again, that the U.S. has relinquished any moral leadership on these issues.”

— with additional reporting by Asawin Suebsaeng and Kimberly Dozier