This post has been updated with Pence's comments about Syrian refugees during Tuesday's vice presidential debate.

Before he was Donald Trump's vice-presidential pick, Indiana Gov. Mike Pence (R) took a politically popular, if legally questionable, stand: There would be no Syrian refugees resettled in his state, not after the attacks in Paris last fall carried out in part by Islamist terrorists who masqueraded as Syrian migrants.

On the day before the vice-presidential debate, his biggest moment as Trump's running mate, Pence's stand on Syrian refugees received a likely fatal blow: A federal appeals court ruled Monday that Pence has no legal authority to stop the resettlement of these refugees in Indiana.

In fact, the three-judge panel — all Republican appointees — said Pence's directive preventing money from going toward resettling Syrian refugees amounted to "discrimination" and was based on "nightmare speculation."

In Tuesday's vice presidential debate, Pence defended the program, but didn't directly address the court ruling:

In the past, Pence has said that preventing Syrians from resettling in the state is a safety issue, given that screening from war-torn countries is difficult. But the court definitely did not see it that way. Here's a key passage from its ruling (which you can read in full here):

He argues that his policy of excluding Syrian refugees is based not on nationality and thus is not discriminatory, but is based solely on the threat he thinks they pose to the safety of residents of Indiana. But that’s the equivalent of his saying (not that he does say) that he wants to forbid black people to settle in Indiana not because they’re black but because he’s afraid of them, and since race is therefore not his motive he isn’t discriminating. But that of course would be racial discrimination, just as his targeting Syrian refugees is discrimination on the basis of nationality.

The court went on to say:

The governor of Indiana believes, though without evidence, that some of these persons were sent to Syria by ISIS to engage in terrorism and now wish to infiltrate the United States in order to commit terrorist acts here. No evidence of this belief has been presented, however; it is nightmare speculation.

In short, the legality of Pence's decision to block Syrian refugees from Indiana wasn't a close call for the judicial branch: It's not legal.

In an added dose of embarrassment for Pence, one of the judges who ruled against him Monday is on Trump's Supreme Court shortlist. Judge Diane Sykes is someone the GOP presidential nominee has said might be a conservative "just like Justice Scalia," the late justice whose seat remains unfilled. Sykes made Trump's list of 11 possible choices he made public in May (it has since nearly doubled).

Pence's Syrian refugee saga started last spring, when he joined about 30 other governors, almost all of them Republican, in trying to keep out of their states the estimated 10,000 Syrian refugees President Obama wanted to resettle.

Refugee resettlement and legal experts immediately questioned the viability of the governors' stance: Federal law says the president, not governors, has the power to decide which refugees come into the country and how many.

And while many of those governors' promises to keep Syrian refugees out — in some cases, "even 5-year-old orphans" — fizzled, Pence's directive stayed in the spotlight. The American Civil Liberties Union and a private refugee resettlement group in the state, Exodus Refugee Immigration, sued Pence. Pence's team was forced to try to defend his directive, and the lawsuit made Indiana a test case in the debate over Syrian refugees.

The intrigue over his legal showdown heightened when Trump picked Pence as his running mate in July. Trump has called for a temporary ban on Muslims and/or people from countries with a history of terrorism. A few days after accepting Trump's offer, Pence used his decision to block Syrian refugees on CBS's "60 Minutes" as a talking point for the campaign's get-tough-on-terrorism message.

"We have no higher priority than the safety and security of the people of this country," he told CBS's Lesley Stahl.

But in August, The Washington Post's Katie Zezima traveled to Indianapolis and found that despite Pence's ban, 140 Syrian refugees had since resettled in the state, with more on the way.

"You can’t pick and choose who comes to your state,” Cole Varga, executive director of Exodus Refugee Immigration, told Zezima.

Apparently the courts agree.

Monday's circuit court ruling affirmed a lower court's ruling. If Pence wanted to appeal the decision, he'd have to appeal to the Supreme Court. Precedent suggests that the court would be unlikely to pick this case up, given that there has been no disagreement among the lower courts.