US President Donald Trump's government has dropped its plans to deport international students whose courses move fully online because of the coronavirus pandemic.
The U-turn comes just one week after the policy announcement.
The Massachusetts Institute of Technology (MIT) and Harvard University sued the government over the plan.
District Judge Allison Burroughs in Massachusetts says the parties have come to a settlement.
The agreement reinstates a policy implemented in March, amid the virus outbreak, which allows international students to attend their classes virtually if necessary and remain legally in the country on student visas, according to the New York Times.
Large numbers of foreign students travel to the US to study every year and are a significant source of revenue for universities.
Harvard announced recently that, because of concerns over the virus's spread, course instruction would be delivered online when students return for the new academic year. MIT, like a number of other educational institutions, said it would also continue to use virtual tuition.
What had the policy said?
Foreign students were told last week that they would not be allowed to stay in the US this autumn unless they switched to a course with in-person tuition.
Those who had returned to their home countries when term ended in March - as the coronavirus crisis grew - were told they would not be permitted to return if their classes had since moved online.
The US Immigration and Customs Enforcement (ICE) agency had said people could face deportation if they did not comply with the rules.
The Student and Exchange Visitor Program, which is run by ICE, had originally permitted foreign students to continue with their spring and summer 2020 courses online while remaining in the country.
But on 6 July the agency said foreign students who then failed to switch to in-person courses could face "immigration consequences including, but not limited to, the initiation of removal proceedings".
How did universities react?
Two days afterwards, Harvard and MIT filed the first of several lawsuits seeking to overturn the directive, calling it "arbitrary, capricious, an abuse of discretion".
Dozens of other universities signed a court brief to support the action.
The "true motivation," the 59 universities argued in their supportive brief, "has nothing to do with ensuring that students engage in a 'full course of study' or with protecting the integrity of the student visa program. Instead, its purpose ... is to 'encourage schools to reopen.'"
The attorneys general of at least 18 states, including Massachusetts and California, also sued.
President Trump has been pushing for university and school students to return to classrooms in the new term. He sees reopening as an indicator of recovery after months of upheaval, which could be beneficial in his bid for reelection in November.
However, many educators are concerned about student wellbeing and want to continue practicing social distancing while the outbreak is ongoing.
Which visas did it affect?
The policy applied to holders of F-1 and M-1 visas, which are for academic and vocational students. The state department issued 388,839 F visas and 9,518 M visas in the fiscal year 2019, according to the agency's data.
According to the US commerce department, international students contributed $45bn (£36bn) to the country's economy in 2018.