President Donald Trump criticised the federal judge who halted his executive order that temporarily banned travel and immigration from seven predominantly Muslim countries.

The signing of the order more than a week ago resulted in global confusion as hundreds of travellers and visa-holding immigrants were detained in airports across the US. It sparked massive protests and several lawsuits against the Trump administration.

His first major defeat as president, Mr Trump did not take news of the restraining order against his action well, and wrongly suggested that any future attack on the US would be the result of the court's action.

"Just cannot believe a judge would put our country in such peril," he wrote, tweeting while on vacation at his Mar-a-Lago resort in Florida. "If something happens blame him and court system. People pouring in. Bad!"

He added that the courts were making the Department of Homeland Security's job "very difficult".

Mr Trump's Twitter attack follows Judge James Robart's blocking of the executive order, plunging the new administration into a crisis and challenging the President's authority – which is not immune to the Judicial Branch of the government.

However, the Trump administration argued to the contrary in their appeal over the weekend.

Activists protest Donald Trump's proposed Muslim ban Show all 11 1 /11 Activists protest Donald Trump's proposed Muslim ban Activists protest Donald Trump's proposed Muslim ban People listen to speakers at a demonstration against racism and conservative presidential candidate Donald Trump's recent remarks concerning Muslims on December 10, 2015 in New York City. Dozens or demonstrators and activists converged at Columbus Circle to denounce the politics of Trump and the treatment of Muslim refugees both in America and Europe. Spencer Platt/Getty Activists protest Donald Trump's proposed Muslim ban People listen to speakers at a demonstration against racism and conservative presidential candidate Donald Trump's recent remarks concerning Muslims on December 10, 2015 in New York City. Dozens or demonstrators and activists converged at Columbus Circle to denounce the politics of Trump and the treatment of Muslim refugees both in America and Europe. Spencer Platt/Getty Activists protest Donald Trump's proposed Muslim ban People listen to speakers at a demonstration against racism and conservative presidential candidate Donald Trump's recent remarks concerning Muslims on December 10, 2015 in New York City. Dozens or demonstrators and activists converged at Columbus Circle to denounce the politics of Trump and the treatment of Muslim refugees both in America and Europe. Spencer Platt/Getty Activists protest Donald Trump's proposed Muslim ban People listen to speakers at a demonstration against racism and conservative presidential candidate Donald Trump's recent remarks concerning Muslims on December 10, 2015 in New York City. Dozens or demonstrators and activists converged at Columbus Circle to denounce the politics of Trump and the treatment of Muslim refugees both in America and Europe. Spencer Platt/Getty Activists protest Donald Trump's proposed Muslim ban People listen to speakers at a demonstration against racism and conservative presidential candidate Donald Trump's recent remarks concerning Muslims on December 10, 2015 in New York City. Dozens or demonstrators and activists converged at Columbus Circle to denounce the politics of Trump and the treatment of Muslim refugees both in America and Europe. Spencer Platt/Getty Activists protest Donald Trump's proposed Muslim ban People listen to speakers at a demonstration against racism and conservative presidential candidate Donald Trump's recent remarks concerning Muslims on December 10, 2015 in New York City. Dozens or demonstrators and activists converged at Columbus Circle to denounce the politics of Trump and the treatment of Muslim refugees both in America and Europe. Getty Activists protest Donald Trump's proposed Muslim ban People listen to speakers at a demonstration against racism and conservative presidential candidate Donald Trump's recent remarks concerning Muslims on December 10, 2015 in New York City. Dozens or demonstrators and activists converged at Columbus Circle to denounce the politics of Trump and the treatment of Muslim refugees both in America and Europe. Spencer Platt/Getty Activists protest Donald Trump's proposed Muslim ban People listen to speakers at a demonstration against racism and conservative presidential candidate Donald Trump's recent remarks concerning Muslims on December 10, 2015 in New York City. Dozens or demonstrators and activists converged at Columbus Circle to denounce the politics of Trump and the treatment of Muslim refugees both in America and Europe. Spencer Platt/Getty Activists protest Donald Trump's proposed Muslim ban People listen to speakers at a demonstration against racism and conservative presidential candidate Donald Trump's recent remarks concerning Muslims on December 10, 2015 in New York City. Dozens or demonstrators and activists converged at Columbus Circle to denounce the politics of Trump and the treatment of Muslim refugees both in America and Europe. Spencer Platt/Getty Activists protest Donald Trump's proposed Muslim ban People listen to speakers at a demonstration against racism and conservative presidential candidate Donald Trump's recent remarks concerning Muslims on December 10, 2015 in New York City. Dozens or demonstrators and activists converged at Columbus Circle to denounce the politics of Trump and the treatment of Muslim refugees both in America and Europe. Spencer Platt/Getty Activists protest Donald Trump's proposed Muslim ban People listen to speakers at a demonstration against racism and conservative presidential candidate Donald Trump's recent remarks concerning Muslims on December 10, 2015 in New York City. Dozens or demonstrators and activists converged at Columbus Circle to denounce the politics of Trump and the treatment of Muslim refugees both in America and Europe. Spencer Platt/Getty

Acting Solicitor General Noel Francisco argued that presidential authority is "largely immune from judicial control" regarding immigration to the US. But the 9th US Circuit Court of Appeals in San Francisco did not agree with that assessment and denied the Justice Department's request to stay the Mr Robart's decision.

The state of Washington was the first to file a lawsuit against the executive order, over which Mr Robart – a George W Bush appointee – presided. In his order, Mr Robart said the states "have met their burden of demonstrating that they face immediate and irreparable injury as a result of the signing and implementation of the Executive Order".

Mr Robart added it is not the court's job to "create policy or judge the wisdom of any particular policy promoted by the other two branches," but rather to make sure that an action taken by the government "comports with our country's laws".

Donald Trump fights back after judge blocks his travel ban

The President was quick to condemn the judge's decision on Twitter.

"The opinion of this so-called judge, which essentially takes law-enforcement away from our country, is ridiculous and will be overturned!" he said.

The President's executive order sought to ban all travel from Iraq, Iran, Yemen, Syria, Libya, Sudan, and Somalia for 90 days. It placed a 120-day ban on refugee admittance from six of those countries, while placing an indefinite halt to acceptance of Syrian refugees.

It also resulted in the revocation of at least 60,000 visas, according to the State Department. The Department of Justice, however, had said that as many as 100,000 had been revoked.

Washington state Attorney General Bob Ferguson celebrated the judge's decision on Friday.