President Trump is waging war on the federal judiciary over court rulings against his Muslim ban. But while he tries to bamboozle his supporters into believing that judges are the enemy and that the separation of powers doesn’t exist, the reality is that he’s getting played by the federal judges who are using what he perceives as his greatest strength — his enormous media platform — against him.

For Trump, the idea that his executive order is a Muslim ban is a point of pride, a way of earning the adoration from his base that he so craves. But that’s exactly what’s getting him into legal trouble: Every time he or one of his advisers has boasted about creating a Muslim ban, those statements have ended up cited in a court order blocking implementation of his executive action.

Last month, after several federal courts, including the Ninth Circuit Court of Appeals, froze Trump’s Jan. 27 executive order barring travel from seven Muslim-majority countries, the president denounced the appellate court’s ruling as “disgraceful” and vowed, via Twitter, “SEE YOU IN COURT.” But rather than pursuing an appeal of the Ninth Circuit’s decision, the administration withdrew the first executive order and issued a new version with only very modest revisions to the first. Citizens, states and refugee resettlement agencies immediately challenged the new order in federal courts around the country, and Wednesday night and Thursday morning courts in Hawaii and Maryland blocked it, too.

One would think that because courts keep blocking the executive orders precisely because the Trump administration keeps admitting that the orders are Muslim bans that perhaps Trump would stop admitting that. But as he demonstrated at a campaign rally in Nashville on Wednesday night, he has no such intention. Dismissing the revised executive order as a “watered-down version,” Trump said, “I think we should go back to the first one and go all the way, which is what I wanted to do in the first place.”

Trump should be prepared for that comment to show up in another court decision as these challenges make their way through the courts.

If Trump and his staff were smart, they would have kept in mind this one sentence from the Ninth Circuit’s decision: “It is well established that evidence of purpose beyond the face of the challenged law may be considered in evaluating Establishment and Equal Protection Clause claims.” In other words, in evaluating the legal challenges to the executive orders, courts are not limited to language of the executive order itself, or to statements made by the government in court. Statements made on Twitter, on Fox News, on Trump’s campaign website are all fair game — and they all sabotaged Trump’s case, once again, in round two.

In issuing the nationwide injunction against the revised executive order Wednesday night, Derrick K. Watson, the federal judge in Hawaii, cited “significant and unrebutted evidence of religious animus driving the promulgation of the Executive Order and its related predecessor.” That evidence included interviews Trump did on CNN and NBC, his statements during presidential debates last fall, a campaign press release, Rudy Giuliani’s admission on Fox News that Trump had asked him to study how he could “legally” implement a “Muslim ban,” and Trump adviser Stephen Miller’s admission that the revised executive order was “still going to have the same basic policy outcome [as the first].”

In the Maryland case, Judge Theodore D. Chuang cited even more public statements by Trump and his surrogates, including statements posted on his campaign website, tweets, and interviews on national television, as well as the Giuliani and Miller comments. The judge also cited Trump’s interview on the Christian Broadcasting Network the same day the first executive order was issued, pledging that Christian refugees would receive preference over Muslims. Again, something Trump saw as a boast — telling an evangelical audience that he was looking out for what they claim is Christian persecution — came back to haunt him.

Yet at Wednesday night’s Nashville rally, Trump only escalated his attacks on the judiciary — and the press. He called the Hawaii ruling “terrible,” adding that “the most dishonest people in the world” would criticize him “for speaking harshly about the courts.” He pitted his followers against the judge, saying that the ruling “makes us look weak, which by the way we no longer are, believe me.” The “system” he went on, “has weakened and endangered our country and left our people defenseless.” But, he vowed, “we’re going to fight this terrible ruling. . . . we’re going to keep our citizens safe.”

His base hears this: The judiciary is putting your very life at risk.

While Trump is losing in court, his provocations to his base are nonetheless extremely dangerous. On Monday, the Senate Judiciary Committee begins confirmation hearings on Trump’s nomination of Neil Gorsuch to fill the late Supreme Court Justice Antonin’s Scalia’s seat. If senators do not question Gorsuch about the independence of the judiciary in light of Trump’s efforts to undermine it, they will be making a mockery of the process and the institution.