Washington may win a partial or full victory this round, but I don’t think it can win in the long run.
Imagine that a judge had asked: “if we knew that Trump acted on anti-Muslim animus AND that the seven countries posed special security threats, what is the right outcome under the Establishment clause?”
The answer must be, I think, that the government wins. Otherwise, the government would be unable to protect people if the president is a bigot. No court would come to that conclusion.
Also note that a court will ultimately have to defer on the security issue; it won’t require deposition of CIA agents. So even if the evidence of a national security threat is less than perfect, the government wins.