The Trump administration on Tuesday dropped its much-criticized plan to require international college students to leave the United States unless they are enrolled in the fall term in at least one face-to-face class.

The abrupt reversal, disclosed in a federal court in Boston, came a little more than a week after U.S. Immigration and Customs Enforcement issued an edict that stunned U.S. higher education leaders and students worldwide.

Under the July 6 policy from ICE, international students enrolled in U.S. colleges and universities for the fall semester faced a mandate to take at least one course in person. Those students, ICE said, “may not take a full online course load and remain in the United States.”

That mandate posed a major obstacle to plans for online teaching and learning that colleges are developing in response to the novel coronavirus pandemic. In the spring, the federal government had given schools much more leeway to teach international students online.

Harvard University and the Massachusetts Institute of Technology had sued to block the new policy. In a hearing in that case on Tuesday, held before U.S. District Judge Allison D. Burroughs, the judge announced that the schools and the federal government had reached an agreement that made the lawsuit moot.

“The government has agreed to rescind the July 6, 2020, policy directive and the frequently asked questions, the FAQ’s, that were released the next day on July 7,” Burroughs said, according to a transcript of the hearing. “They have also agreed to rescind any implementation of the directive.”

The judge said the agreement reverted policy to “the status quo” that had been developed in March, when schools nationwide were forced to halt in-person teaching because of the pandemic. Campuses have been sparsely populated in the months since.

An assistant U.S. attorney who participated in the hearing, Rayford A. Farquhar, confirmed the judge’s understanding of the agreement, according to the transcript.

The Department of Homeland Security and ICE, a unit of the department, had no immediate comment.

Harvard has about 5,000 international students and MIT, about 4,000.

In their suit, Harvard and MIT argued that the Trump administration’s action violated the Administrative Procedure Act, which governs how federal agencies make rules. They also claimed the ICE decision was a political move calculated to force universities to reopen campuses and hold classes in person despite the soaring toll of the coronavirus in death and illness.

Scores of universities supported their lawsuit, along with more than 70 higher education associations. So did Google, Twitter, Facebook and more than a dozen other tech companies.

Separately, 20 state attorneys general had also challenged the guidance in court in recent days.

Massachusetts Attorney General Maura Healey, a leader in that effort, celebrated the outcome. “This ICE rule was senseless and illegal the minute it came out, and the Trump Administration knew it didn’t have a chance,” Healey said in a statement. “This is why we take action in court, why we stand up for our values, and why we will remain vigilant in protecting our international students from these harmful disruptions.”

Other universities had pushed back as well. Last week, Johns Hopkins University filed suit in federal court in the District of Columbia, arguing that the ICE rule was illegal and unconstitutional.

A coalition of 20 universities in the western United States, including Stanford University, the California Institute of Technology, the University of Southern California and the University of Oregon, had also filed a lawsuit Monday seeking to overturn the order.

“We are deeply grateful that the administration agreed to drop this poorly designed, counterproductive policy regarding international students,” said Terry W. Hartle, senior vice president of the American Council on Education. The council represents college and university leaders nationwide.

“The administration just had a clunker,” Hartle said. “At the end of the day, they decided they didn’t even want to try to defend it.”

There are hundreds of thousands of international students in the United States. Tuesday’s news signaled a reprieve from a policy that threatened to disrupt their education.

“Oh man, I’m ecstatic,” said Azan Zahir Virji, 25. “I’m so glad to hear it. I’m so thankful.”

In the last week, Virji had panicked, worried that he would not be able to continue his education at Harvard Medical School. His parents in Tanzania, a former hairstylist and an electrician, were trying to find money for a flight home for him. He was worrying about the expense, the risk of exposing them to coronavirus and whether his education would be entirely disrupted.

“It was always their dream to see me become a physician,” he said. “To get so close to it and almost lose it all, that was scary for them.”

So when Virji saw the news, through a tweet from another international student popping in at the end of an online class Tuesday, he raised his arms in the air, thrilled and relieved.

Even in the midst of his celebration, he still had a worry, he said. When he came to the United States in 2013 to attend Yale University, the idea of a visa being revoked or a student being deported seemed all but impossible, he said. Now, he feels differently. “I think this sentiment against immigrants is going to continue to grow. That’s in the back of my mind, thinking, ‘Am I still welcome here?’