A US judge has issued a temporary restraining order blocking the Trump administration from enforcing a ban the president ordered barring Harvard University from accepting international students.

The order by Judge Allison Burroughs, who is based in Massachusetts, said the oldest university in the US would face "immediate and irreparable injury" if the proclamation went into effect.

It comes in response to a lawsuit filed by Harvard on Thursday accusing President Donald Trump of waging a "government vendetta" intended to stifle free speech.

Trump has argued that the ban is necessary on national security grounds, and has accused Harvard of not doing enough to stop antisemitism on campus.

The federal judge's order comes only hours after Harvard amended an existing lawsuit against the US government, claiming that Trump's move is "part of a concerted and escalating campaign of retaliation by the government in clear retribution for Harvard's exercising its First Amendment rights" to free speech.