WASHINGTON (AP) — A federal appeals court denied early Sunday the Justice Department’s request for an immediate reinstatement of President Donald Trump’s ban on accepting certain travelers and all refugees.

The Trump administration appealed a temporary order restraining the ban nationwide, saying late Saturday night that the federal judge in Seattle overreached by “second-guessing” the president on a matter of national security.

Now the higher court’s denial of an immediate stay means the legal battles over the ban will continue for days at least. The 9th U.S. Circuit Court of Appeals in San Francisco asked challengers of the ban respond to the appeal, and for the Justice Department to file a counter-response by Monday afternoon.

Acting Solicitor General Noel Francisco forcefully argued Saturday night that the president alone has the power to decide who can enter or stay in the United States — an assertion that appeared to invoke the wider battle to come over illegal immigration.

“The power to expel or exclude aliens is a fundamental sovereign attribute, delegated by Congress to the executive branch of government and largely immune from judicial control,” the brief says.

Earlier Saturday, the government officially suspended the ban’s enforcement in compliance with order of the order of U.S. District Judge James Robart. It marks an extraordinary setback for the new president, who only a week ago acted to suspend America’s refugee program and halt immigration from seven Muslim-majority countries the government said raise terrorism concerns.

Trump, meanwhile, mocked Robart, who was appointed by President George W. Bush, calling him a “so-called judge” whose “ridiculous” ruling “will be overturned.”

“Because the ban was lifted by a judge, many very bad and dangerous people may be pouring into our country. A terrible decision,” he tweeted.

Trump’s direct attack recalled his diatribes during the campaign against the federal judge of Mexican heritage who oversaw lawsuits alleging fraud by Trump University, and may prompt some tough questions as these challenges rise through the courts.

But the government’s brief repeatedly asserts that presidential authority cannot be questioned by judges once the nation’s security is invoked.

Congress “vests complete discretion in the President” to impose conditions on alien entry, so Trump isn’t legally required to justify such decisions, it says. His executive order said the ban is necessary for “protecting against terrorism,” and that “is sufficient to end the matter.”

The Justice Department asked that the federal judge’s order be stayed pending resolution of the appeal, so that the ban can “ensure that those approved for admission do not intend to harm Americans and that they have no ties to terrorism.”

The order had caused unending confusion for many foreigners trying to reach the United States, prompted protests across the United States and led to multiple court challenges. Demonstrations took place outside the White House, in New York and near his estate in Palm Beach, Florida, where Trump was attending the annual American Red Cross fundraising gala.

“We’ll win,” Trump told reporters Saturday night. “For the safety of the country, we’ll win.”

The State Department, after initially saying that as many as 60,000 foreigners from Iraq, Syria, Iran, Sudan, Libya, Somalia or Yemen had their visas canceled, reversed course on Saturday and said they could travel to the U.S. if they had a valid visa.

The department on Saturday advised refugee aid agencies that refugees set to travel before Trump signed his order will now be allowed in. A State Department official said in an email obtained by The Associated Press that the government was “focusing on booking refugee travel” through Feb. 17 and working to have arrivals resume as soon as Monday.

The Homeland Security Department no longer was directing airlines to prevent visa-holders affected by Trump’s order from boarding U.S.-bound planes. The agency said it had “suspended any and all actions” related to putting in place Trump’s order.

Hearings have also been held in court challenges nationwide. Washington state and Minnesota argued that the temporary ban and the global suspension of the U.S. refugee program harmed residents and effectively mandated discrimination.

In his written order Friday, Robart said it’s not the court’s job to “create policy or judge the wisdom of any particular policy promoted by the other two branches,” but rather, to make sure that an action taken by the government “comports with our country’s laws.”

The Justice Department countered that “judicial second-guessing of the President’s national security determination in itself imposes substantial harm on the federal government and the nation at large.”

Robart’s order also imposes harm on U.S. citizens “by thwarting the legal effect of the public’s chosen representative,” it says.

___

Associated Press writers Michael Warren in Atlanta, Alicia A. Caldwell, Mark Sherman, Matthew Lee and Jessica Gresko in Washington, Martha Bellisle in Seattle, William Mathis and Julie Walker in New York, contributed to this report.

Copyright 2017 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.