Image copyright AFP Image caption The proposed travel ban has drawn protests across the US

Federal judges in Hawaii and Maryland have blocked US President Donald Trump's new travel ban, which was due to begin after midnight on Thursday.

The order would have placed a 90-day ban on people from six mainly Muslim nations and a 120-day ban on refugees.

Both judges questioned the legality of the ban, which critics say is discriminatory.

President Trump insists the move is to stop terrorists from entering the United States.

He complained of "unprecedented judicial overreach".

An earlier version of the order, issued in late January, sparked confusion and protests, and was blocked by a judge in Seattle.

In Hawaii, District Judge Derrick Watson cited "questionable evidence" in the government's argument that the ban was a matter of national security.

US District Judge Theodore Chuang, sitting in Maryland, also ruled it was meant to be a ban on Muslims, and therefore violated the First Amendment.

Hawaii state had argued that the ban would harm tourism and the ability to recruit foreign students and workers, while in Maryland the plaintiffs argued it discriminated against Muslims and illegally reduced to number of refugees being accepted for resettlement in the US.

Media playback is unsupported on your device Media caption Attorney General of Hawaii, Doug Chin, said "hostility towards a particular religion...violated the constitution"

What did the judges say?

Judge Watson said the court had established a strong likelihood that, were the ban to go ahead, it would cause "irreparable injury" by violating First Amendment protections against religious discrimination.

In his 43-page ruling, he argued that a "reasonable, objective observer" taking into account the context of the Executive Order would conclude it "was issued with a purpose to disfavour a particular religion".

It notes statements made by Mr Trump such as a 2015 press release calling for "a total and complete shutdown of Muslims entering the United States", and his adviser Rudolph Guiliani, who said in a television interview in January: "When [Mr Trump] first announced it, he said: 'Muslim ban'. He called me up. He said: 'Put a commission together. Show me the right way to do it legally.'"

It also says there is a "dearth of evidence indicating a national security purpose".

In his ruling, Judge Chuang wrote: "To avoid sowing seeds of division in our nation, upholding this fundamental constitutional principle at the core of our nation's identity plainly serves a significant public interest."

What does Mr Trump say?

Speaking at a rally in Nashville, Tennessee on Wednesday evening, Mr Trump said the ruling in Hawaii was "flawed" and a case of "unprecedented judicial overreach".

His administration argues that the constitution gives the president the power to suspend immigration when he deems it to be in the national interest of the country, and that neither the initial or revised orders discriminate on the basis of religion.

Justice department lawyers argue that the revised ban is an extension of President Obama's move towards stricter screening of travellers from the six countries.

Media playback is unsupported on your device Media caption "This is, in the opinion of many, an unprecedented judicial overreach" - President Trump

Back to the drawing board: Anthony Zurcher, BBC News, Washington

Donald Trump's first travel ban was suspended because it probably violated the due process rights of individuals with valid residency papers and visas. The battle over whether it imposed an unconstitutional religious test on certain immigrants was put off until another day. That day has arrived.

In its decision, the federal court in Hawaii used Mr Trump's own words - and the words of his advisers - against him. The text of the executive order, Judge Derrick Watson held, could not be separated from the context of the recent presidential campaign, "Muslim ban" rhetoric and all. An order that discriminates against some Muslims, he continued, is just as legally deficient as one that discriminates against them all.

Now it's back to the drawing board for the Trump administration or - perhaps an even gloomier prospect - back to the Ninth Circuit court of appeals, which ruled against the president on the original ban just last month.

After Mr Trump's previous adverse legal ruling, he angrily tweeted: "We'll see you in court." Although it took a new travel order to get there, it turns out he was right.

What happens next?

Mr Trump said he will take the case "as far as it needs to go", including to the US Supreme Court.

In both cases, this is only the first step. An appeal against the Hawaii decision would be expected to go next to the Ninth Circuit Court of Appeals - the same court which in February said it would not block a ruling by a Seattle court to halt the original travel ban.

However, also on Wednesday, five judges at that court wrote a letter saying they believed that decision was an "error", and the first Executive Order was "well within the powers of the presidency".

California, Massachusetts, New York, Oregon and Washington state are all taking part in legal actions against the revised ban.

Washington state Attorney General Bob Ferguson, who is attending a court hearing in Seattle in his efforts to block the travel ban, described the ruling as "fantastic news".

"It's very exciting. At this point it's a team effort - multiple lawsuits and multiple states," he said.

Who does the travel ban affect?

Media playback is unsupported on your device Media caption New US travel ban: What's different?

Under the revised order, citizens of six countries on the original 27 January order - Iran, Libya, Syria, Somalia, Sudan and Yemen - would once more be subject to a 90-day travel ban.

Iraq was removed from the list because its government had boosted visa screening and data sharing, White House officials said.

The revised order also lifts an indefinite ban on all Syrian refugees and says Green Card holders (legal permanent residents of the US) from the named countries will not be affected.