Updated at 2:57 p.m. ET

The U.S. Supreme Court agreed to review a series of lower-court rulings blocking the Trump administration’s controversial travel ban on Monday, setting up a major showdown over presidential power and religious discrimination.

In an unsigned order issued on the Court’s last day before its summer recess, the justices scheduled oral arguments in the case for when they return in October. They also partially lifted the lower courts’ injunctions against Section 2(c) of President Trump’s executive order, which temporarily suspended visa applications from six Muslim-majority countries, as well as Section 6, which froze the U.S. Refugee Admissions Program and halted refugee entry into the United States.

Under the Court’s order, the Trump administration can enforce the ban to block “foreign nationals who lack any bona fide relationship with a person or entity in the United States” from the six targeted countries while the case proceeds. It’s unclear how broad or narrow that restriction will be in practice.

“In practical terms, this means that §2(c) may not be enforced against foreign nationals who have a credible claim of a bona fide relationship with a person or entity in the United States,” the Court said. “All other foreign nationals [from the six targeted countries] are subject to the provisions of EO–2.”

Justice Clarence Thomas wrote separately to say he would have granted the Trump administration’s request to block the lower court injunctions in their entirety while legal proceedings unfold. “Today’s compromise will burden executive officials with the task of deciding—on peril of contempt— whether individuals from the six affected nations who wish to enter the United States have a sufficient connection to a person or entity in this country,” he wrote. Samuel Alito and Neil Gorsuch joined his opinion.

In addition to the underlying issues at stake, the Court also asked both sides to file briefs on whether the second executive order expired on June 14. When Trump signed the order on March 16, it included a provision that Section 2(c)’s visa suspensions would only last for 90 days “from the effective date” of the order. Once Section 2(c) expires, legal challenges to it become moot.

The lower courts did not suspend that provision or even acknowledge it, meaning the 90-day clock theoretically kept ticking. Trump signed a memo on June 14 that claimed to amend the provision until legal proceedings conclude. “The Government takes the view that, if any mootness problem existed previously, the President’s memorandum has cured it,” the Court noted. But the justices nonetheless ordered both sides to weigh in on the question.

If the Court rules on the merits, the case is likely to result in a major precedent on the scope of the presidency’s national-security powers. It will also be Trump’s first showdown with the Supreme Court after months of battles in the federal appellate courts over his first and second executive orders on the travel ban. Presidents of both parties often find themselves stymied by the Court at some point during their administrations. But Trump will face a high-profile judicial test of one of his core policies far earlier than most of his predecessors.

In a statement shortly after the announcement, the president said he was “gratified” by the Court’s move. “Today’s unanimous Supreme Court decision is a clear victory for our national security,” Trump said. “It allows the travel suspension for the six terror-prone countries and the refugee suspension to become largely effective.”

The Department of Homeland Security said it would begin enforcing the ban after reviewing the ruling with the Justice and State departments. “The implementation of the executive order will be done professionally, with clear and sufficient public notice, particularly to potentially affected travelers, and in coordination with partners in the travel industry,” the department said in a statement.

The president signed the first iteration of his travel ban in January with little warning, leading to chaos and protests at major U.S. airports. Multiple federal courts soon blocked the government from enforcing the order pending judicial review. After a three-judge panel in the Ninth Circuit Court of Appeals approved a nationwide injunction against the ban in February, the administration said it would rewrite the order.

Trump signed the revised order on March 6 and scheduled it to go into effect on March 16. The second version removed Iraq from the list of targeted countries and included more exemptions to the freeze on visa applications. But federal judges in Hawaii and Maryland issued injunctions against the order less than 24 hours before it went into force. In June, a frustrated Trump castigated the Justice Department and railed against the order he signed as a “watered down, politically correct version.” He also attacked the courts as “slow and political.”

Two federal appeals courts subsequently ruled against the second ban. The Fourth Circuit upheld the injunction in Maryland on constitutional grounds in May, citing the president’s campaign rhetoric to conclude that the executive order “drips with religious intolerance, animus, and discrimination.” In the Ninth Circuit, a three-judge panel left most of the injunction in Hawaii intact on statutory grounds, ruling that the administration had not sufficiently proven the order was necessary for national security. The Justice Department vowed to appeal both cases to the Supreme Court.

Civil-rights groups challenging the orders have assailed them as vehicles to implement the Muslim ban that Trump once proposed on the campaign trail. “President Trump’s Muslim ban violates the fundamental constitutional principle that government cannot favor or disfavor any one religion,” Omar Jadwat, the director of the ACLU’s Immigrants’ Rights Project, said in a statement Monday. “Courts have repeatedly blocked this indefensible and discriminatory ban. The Supreme Court now has a chance to permanently strike it down.”