Harvard won a temporary victory on Thursday in a legal battle with the Trump administration over whether it can enroll international students, after a federal judge said that the university could continue to do so for now.

The judge, Allison D. Burroughs, said she would extend an order from last week blocking the government’s attempts to prevent international students from enrolling at the school as the two sides continue to argue the matter in court.

At the same time, lawyers for the Department of Homeland Security hinted that the Trump administration was pursuing other ways to bar international students from enrolling at the Ivy League university.

The Trump administration had been trying to ban international students at Harvard as part of a multipronged attack against the school, which has included halting billions in federal funds. Government officials have accused the school of harboring antisemitism and, in a court filing on Thursday, also accused the school of working with the Chinese Communist Party.

The government has not offered any particular evidence for these claims, and Harvard officials have maintained they are in full compliance with legal requirements to report foreign donations. The university has accused the Trump administration of violating its First Amendment rights and targeting it as part of a political crusade.

Its lawyers have cited a barrage of social media posts by President Donald Trump that attack the university and its professors for their political ideology.

Harvard sued the Trump administration last week after the government announced that it would revoke the university’s authorization to enroll students from abroad. Hours after the lawsuit was filed, Burroughs issued a short-term ban on those efforts.

In the Thursday hearing in federal district court in Boston, the judge voiced concerns that the government was in violation of that earlier order by attempting to prevent foreign students from enrolling. She cited complaints in a filing late Wednesday by Harvard, which included examples of its students being hassled at airports.

The Trump administration sent a last-minute notice offering the university an additional 30 days to respond to its demands just hours before squaring off against Harvard’s lawyers in federal court.

During the hearing, lawyers for the government argued that a court order blocking the Trump administration’s action would be unnecessary given the extension. But Burroughs said she wanted to issue an injunction anyway, repeating concerns that student visas were being delayed or rescinded.

“I have to say that I would feel more comfortable if an order were in place,” Burroughs responded, agreeing with a lawyer for Harvard, Ian Gershengorn.

Gershengorn argued that an order was still necessary because of what he called the Trump administration’s ongoing violations of the school’s First Amendment rights, and suggesting that the new notice from the government was merely another step in the government’s maneuvering.

“There seems to be a different set of rules, procedures for Harvard,” he said, adding that the “harms we are suffering are real and continuing.”

Karoline Leavitt, the White House press secretary, suggested on Thursday that Burroughs was overreaching.

“If these judges want to be secretary of state or the president, they can run for office themselves,” she said.

International students make up about a quarter of Harvard’s student body, and are critical to the university’s academics and finances. The school had asked for the extension so that international students, many of whom had left campus for the summer, could return to Harvard for their studies while the litigation continues.

An extension would also clear the way for incoming first-year students from abroad to proceed with their plans.

Jason A. Newton, a Harvard spokesperson, said in a statement that Harvard would “continue to take steps to protect the rights of our international students and scholars, members of our community who are vital to the University’s academic mission and community — and whose presence here benefits our country immeasurably.”

An overflow crowd of onlookers jammed into a Boston federal courtroom Thursday to hear arguments. Court officers seated five people on benches that normally seat four, apologizing for what they called a crowded “Disneyesque” arrangement.

Among those attending was a Japanese legal scholar visiting Harvard on a special visa, who expressed concern that it would be revoked.

During Harvard’s main commencement ceremony on Thursday morning, a murmur went through the crowd as students and families began to learn of the hearing’s outcome. Some people cheered.

The Trump administration has argued that Harvard lost its right to admit international students because of its inability to curb antisemitism on campus, among other allegations. Harvard leaders have acknowledged some problems with antisemitism, but said the school had taken many steps to address them.

The government’s filing on Thursday morning appeared to be a legal maneuver to delay, if not change, the ultimate outcome in the case by including, for the first time, numerous allegations of what the government described as “serious concerns” about the influence of foreign funding at the school.

It also sought to address a procedural claim that the administration had not followed the proper method of notification when it abruptly announced its ban on international students, said David Super, an administrative law expert at Georgetown University.

“An obvious violation like this procedural one is going to be a simple way for the court to rule against the government, and the government wanted to remove that,” he said.