Harvard and MIT asked a court on Wednesday to block an order by US President Donald Trump’s administration threatening the visas of foreign students whose entire courses have moved online because of the coronavirus pandemic.

The universities’ lawsuit was in response to an announcement on Monday by the US Immigration and Customs Enforcement (ICE) that the affected students must leave the country or transfer to a school offering in-person tuition.

“We will pursue this case vigorously so that our international students, and international students at institutions across the country, can continue their studies without the threat of deportation,” Harvard president Lawrence Bacow said in a statement.

Trump is pushing universities and schools to fully open when the new academic year starts in September despite the US registering record Covid-19 cases.

ICE said in its announcement that the State Department would not issue visas to students enrolled in programmes that are fully online for the autumn semester and such students would not be allowed to enter the country.

Universities with a hybrid system of in-person and online classes will have to show that foreign students are taking as many in-person classes as possible to maintain their status.

The measure was seen as a move by the White House to put pressure on educational institutions that are adopting a cautious approach to reopening amid the pandemic.

Bacow said: “The order came down without notice – its cruelty surpassed only by its recklessness.”

He said it was made “without regard to concerns for the health and safety of students, instructors and others”.

The universities say in their lawsuit that the order would harm students “immensely”, both personally and financially.

It describes the order as “arbitrary and capricious” and says it threw US higher education “into chaos”.

There were more than one million international students in the US for the 2018-2019 academic year, according to the Institute of International Education (IIE).

The plaintiffs ask that the court issue a temporary restraining order and “permanent injunctive relief” preventing the policy from being enforced.

They also ask that the order be declared unlawful, that their legal costs are covered, and that they receive any other relief that the court deems appropriate.

The lawsuit, filed in Boston, lists the defendants as ICE and the US Department of Homeland Security.