HARVARD UNIVERSITY and the Massachusetts Institute of Technology on Wednesday filed a federal lawsuit attempting to block the Trump administration’s new policy ordering international students to leave the country if their college or university is offering online-only classes in the fall.

Most fall courses at Harvard and MIT are being held remotely this fall out of concern over the spread of COVID-19 on campus. Many other schools in Massachusetts and across the country are in similar positions.

“If allowed to stand, ICE’s policy would bar hundreds of thousands of international students at American universities from the United States in the midst of their undergraduate or graduate studies,‘’ Harvard and MIT wrote in the complaint. “ICE’s decision reflects a naked effort by the federal government to force universities to reopen all in-person classes notwithstanding their informed judgment that it is neither safe nor advisable to do so. The effect — perhaps even the goal—is to create chaos for schools and international students alike.”

In the suit filed in US District Court in Boston, the institutions seek a temporary restraining order that would put the US Immigration and Customs Enforcement directive on hold for 14 days. The schools are also seeking permanent injunctive relief preventing the policy from being enforced because the Trump administration failed to offer any reasonable basis to justify the policy and didn’t provide the public with notice or opportunity to comment, both of which are required under federal law. The universities asked the federal court to schedule a court date today.

Harvard and MIT said they had previously relied on a March 2020 Department of Homeland Security guidance that allowed foreign students in the US to remain legally taking online courses and authorized the entry of new foreign students to arrive for the next semester.

The Trump administration’s directive, announced Monday, would limit foreign student’s visas, known as F-1 visas. Students overseas seeking to come into the country or those already issued those visas would not be allowed into the country to take online courses here.

ICE has not replied to requests for comment on the lawsuit. However, acting Deputy Secretary Kenneth Cuccinelli said on CNN Tuesday that “if they’re not going to be a student, or they’re going to be 100 percent online, then they don’t have a basis to be here.”

Harvard said the move would prevent the university’s approximately 5,000 international students from remaining in the country.

MIT has a little over 3,800 students with F-1 visas, including students on a visa called optional practical training, which allows them to work here 12 months before and after completing their academic studies. MIT said that students on a science and engineering version of the visa, called STEM OPT, would also be impacted. The university is awaiting 459 newly admitted students for the fall semester that have not yet come to the United States.

“Our international students now have many questions – about their visas, their health, their families and their ability to continue working toward an MIT degree. Unspoken, but unmistakable, is one more question: Am I welcome? At MIT, the answer, unequivocally, is yes,” said MIT president L. Rafael Reif, himself an immigrant from Venezuela, in a message to students.

In a message to faculty and staff, Harvard president Lawrence Bacow said the order from the federal government “came down without notice – it’s cruelty surpassed only by its recklessness.”

Bacow said the directive appeared to be designed “purposefully to place pressure on colleges and universities to open their on-campus classrooms for in-person instruction this fall,” which he said endangers the health of students and professors.

MIT has already announced most fall semester classes have been moved online. Chancellor Cynthia Barnhart wrote in a court filing, “MIT’s goal is to welcome all students back to campus for in-person learning as soon as it can responsibly do so. At this point, however, it would not be feasible for MIT to safely implement Institute-wide, in-person learning for the fall 2020 semester.”

The schools said there are concerns that some students could face risk of arrest or other persecution if they were deported to their home countries because of their sexual orientation and gender identity.

The universities said students attempting to remote learn in their home counties could face issues with restricted internet access, internet firewalls imposed by their countries, and social unrest. The schools said the new policy could prevent students from recouping the cost of airline tickets.

The Cambridge-based universities aren’t the only ones facing upheaval. In the UMass system, 7,000 of 75,000 students are international and would have to leave the country if they are not enrolled in in-person courses.

Attorney General Maura Healey wrote Tuesday that she is also preparing a lawsuit to stop the federal regulations from happening. “Not on my watch” she said, noting that the state is home to thousands of international students.

At the federal level, US Rep. Ayanna Pressley is “exploring every lever at her disposal” to reverse this decision, according to a senior aide. Sen. Ed Markey is considering potential legislation in response.

At a Tuesday press conference, Gov. Charlie Baker slammed the move by ICE as “premature.”

“People ought to make the decisions they need to make in the time they need to make them with the best information they have. I think this one was a little premature,” Baker told reporters.