WASHINGTON (Reuters) - The U.S. Supreme Court’s conservative majority appeared poised to hand President Donald Trump a huge legal victory, signaling on Wednesday it was likely to uphold his contentious travel ban targeting several Muslim-majority countries.

Conservative justices including Chief Justice John Roberts and Anthony Kennedy, a frequent swing vote on the nine-member court, indicated during arguments in the high-profile case their unwillingness to second-guess Trump on the national security justifications offered for the policy.

Trump has said the ban is needed to protect the United States from attacks by Islamic militants.

The challengers, led by the state of Hawaii, have argued the policy was motivated by Trump’s enmity toward Muslims. Lower courts have ruled against each of the three versions put forward by Trump of the travel ban, concluding they violated federal immigration law and the U.S. Constitution’s prohibition on the government favoring one religion over another.

But with five conservatives on the nine-member Supreme Court, Trump seemed likely to be on the winning side when the justices issue their ruling by the end of June.

“My only point is that if you look at what was done, it does not look at all like a Muslim ban,” Conservative Justice Samuel Alito said.

Some of the four liberal justices expressed sympathy toward Hawaii’s arguments, although it appeared possible at least one might eventually side with Trump.

Trump called for “a total and complete shutdown of Muslims entering the United States” as a candidate, and the travel ban has been one of the most controversial policies of his presidency.

The current version, announced in September, prohibits entry into the United States of most people from Iran, Libya, Somalia, Syria and Yemen. No one from those countries has carried out an attack in the United States.

Slideshow ( 10 images )

The high court in June and December 2017 allowed two versions of the ban to take effect while court challenges ran their course. The justices had not until Wednesday heard arguments on the merits of the policy.

The challengers said the U.S. Congress historically has rejected nationality bans in immigration laws, and that Trump’s policy has circumvented that judgment.

Roberts questioned whether the president could be restricted from taking “any targeted action” on foreign policy emergencies, such air strikes in Syria, affecting Muslim countries.

“Does that mean he can’t because you would regard that as discrimination against a majority-Muslim country?” Roberts asked.

‘CONTINUING DISCRETION’

Kennedy, who sometimes joins the liberals in major rulings, pushed back on the notion pressed by the challengers that the ban was permanent, noting that the policy includes a requirement for reports every 180 days that could lead to the removal of a targeted country.

“That indicates there will be a reassessment,” Kennedy said, “and the president has continuing discretion.”

Trump’s conservative appointee to the court, Neil Gorsuch, suggested the lawsuits challenging the ban brought by Hawaii and others should not even have been considered by courts.

Slideshow ( 10 images )

Trump’s hardline immigration policies have been a key part of his presidency. He also has moved to rescind protections for young immigrants sometimes called Dreamers brought into the United States illegally as children, acted against states and cities that protect illegal immigrants, intensified deportation efforts and pursued limits on legal immigration.

Trump administration lawyer Noel Francisco said comments the president made as a candidate should be off-limits from court scrutiny because he had not yet taken office.

Kennedy signaled courts should be able to review candidates’ words, giving the example of a local mayor who makes discriminatory statements and then two days after taking office acts on them.

“You would say that whatever he said in the campaign is irrelevant?” Kennedy asked Francisco.

Liberal Justices Elena Kagan and Justice Sonia Sotomayor pressed Francisco on what kind of campaign trail behavior could be considered by courts. Kagan asked whether a hypothetical “out-of-the-box,” vehemently anti-Semitic candidate would be subject to court review if upon taking office he announced policies targeting Israel.

But Kagan also acknowledged the administration’s concerns about courts judging national security decisions.

Chad was on the list of countries targeted by Trump that was announced in September, but he removed it on April 10. Iraq and Sudan were on earlier versions of the ban.

Venezuela and North Korea also were targeted in the current policy. Those restrictions were not challenged in court.

Travel ban opponents who attended the argument compared a potential ruling upholding Trump’s travel ban with the court’s heavily criticized 1944 decision that endorsed the internment of Japanese Americans during World War Two.

“I hope that as a country we will realize that would be shameful,” National Immigration Law Center Executive Director Marielena Hincapié said.