BOSTON (CN) — Harvard and the Massachusetts Institute of Technology hit the Trump administration with a federal complaint Wednesday over a rule that says foreign students must take classes in person to stay in the country.

“The order came down without notice — its cruelty surpassed only by its recklessness,” Harvard president Lawrence Bacow wrote in an e-mail.

There are about 1 million foreign students in the U.S., and the order could cause large numbers of them to leave, Boston immigration attorney Brian O’Neill said in an interview.

This would create “a huge economic loss” in university towns, added Micol Mion, another Boston immigration attorney, because foreign students lease apartments, buy cars and do a lot of shopping.

Universities also face heavy economic losses because foreign students typically pay full tuition and many might decide to quit if they can’t stay in the U.S. for the cultural experience, the lawyers both said.

Immigration and Customs Enforcement, a subdivision of the Department of Homeland Security, issued the order Monday, altering emergency guidelines that had been put in place as the government navigates the coronavirus pandemic. Previously, ICE had said foreign students could stay in the U.S. and take online-only classes in the spring and summer semesters.

Now, however, “the U.S. Department of State will not issue visas to students enrolled in schools and/or programs that are fully online for the fall semester nor will U.S. Customs and Border Protection permit these students to enter the United States,” the order states.

“Students currently in the United States enrolled in such programs must depart the country or take other measures, such as transferring to a school with in-person instruction.” Otherwise, “they may face immigration consequences including, but not limited to, the initiation of removal proceedings.”

The order was issued just hours after Harvard announced that all its fall classes would be held online and that the university would house residential students at only 40% capacity.

“We believe that the ICE order is bad public policy, and we believe that it is illegal,” Bacow wrote, according to the Harvard Crimson.

Massachusetts Attorney General Maura Healey announced her own plans on Tuesday to sue over the order, which she also called “cruel” and “illegal.” But Harvard and MIT filed their own suit anyway.

The Chronicle of Higher Education criticized the order in a scathing editorial, calling it “ignorant and ominous” and a form of “extortion” aimed at requiring colleges to fully reopen in the fall or lose their international students.

“It creates a host of problems — pedagogical, financial, ethical — for higher education, an industry that many conservatives, particularly Trumpian conservatives, absolutely love to hate,” the editorial states.

But the editorial did not say why foreign students cannot take online classes overseas, other than noting that some students have signed leases here or might have to quarantine temporarily if they return home.

Students can apply for a hardship exemption to Customs and Border Protection. But Mion said a financial hardship such as having signed a lease probably wouldn’t qualify.

The CBP will apply the new rule “extremely strictly,” O’Neill predicted. “They’re not going to be nice about it.”

Mion said the rule could lead to a “brain drain” because talented students who can’t get a cultural experience in the U.S. will apply to schools in Canada, Australia and other countries, and stay there after graduation.

O’Neill predicted that a federal court might be willing to slow down the implementation of the order but that ultimately it would be upheld.

Citing agency policy on pending litigation, a representative for ICE declined to comment on Harvard and MIT’s suit.

The lawsuit brought by Harvard and MIT seeks a temporary restraining order and preliminary and permanent injunctive relief.

“As a university with a profound commitment to residential education, we hope and intend to resume full in-person instruction as soon as it is safe and responsible to do so,” Harvard’s Bacow wrote.

“But, until that time comes, we will not stand by to see our international students’ dreams extinguished by a deeply misguided order,” Bacow added. “We owe it to them to stand up and to fight — and we will.”