As a number of legal experts warned, Donald Trump’s tweets about his “travel ban” helped convince an appeals court to block the controversial plan. It’s the second time his own comments have helped the courts knock down the executive order.
The 9th Circuit Court of Appeals issued a decision on Monday, ruling that Trump’s attempt to block immigration from six predominantly Muslim countries “exceeded the scope of the authority delegated to him by Congress.”
In their ruling, the judges cited a tweet from the president that was posted after the recent terrorist attack in London, in which Trump argued that the U.S. needed a travel ban “for certain dangerous countries.”
The Trump tweet was cited in a footnote in the decision, at a point where the court questioned the justification for the ban.
“The Order seeks to ban people from specific countries, but it does not provide any link between an individual’s nationality and their propensity to commit terrorism or their inherent dangerousness,” the judges said. “In short, the Order does not provide a rationale explaining why permitting entry of nationals from the six designated countries… would be detrimental.”
Get Data Sheet, Fortune’s technology newsletter.
The court also noted that press secretary Sean Spicer recently confirmed that Trump sees his tweets as official statements from the White House.
Immediately after the president posted his thoughts on the travel ban in the wake of the London attacks, a number of people were quick to respond that this was probably unwise, given the fact that the immigration order was still before the courts.
The American Civil Liberties Union, for example, warned in a tweet that it was planning to use Trump’s tweets as evidence in its ongoing fight against the order.
Even someone fairly close to Trump—George Conway, a New York lawyer and husband of Trump adviser Kellyanne Conway—suggested that posting such comments was unwise. “These tweets may make some ppl feel better, but they certainly won’t help OSG get 5 votes in SCOTUS, which is what actually matters,” he said.
Conway went on to say that he was a big supporter of Trump and of the immigration ban, but added that tweets from the administration on legal matters “seriously undermine Admin agenda and POTUS.”
To make matters worse, Trump didn’t stop at one tweet about the ban (which his own administration had previously argued was not actually a ban, and shouldn’t be referred to as such). The president said that he supported his original order, not the “watered down, politically correct version” that his own advisers had convinced him to sign.
That earlier version of the law was struck down by two lower courts because it was targeted at Muslims, and blocking travel based on a person’s religion is unconstitutional.
“I think he shot himself in the legal foot,” Cornell Law School immigration professor Stephen Yale-Loehr said of Trump’s comments about his preference for the original version of the ban.
One would think that the Trump administration or the president himself may be more careful with posts on Twitter about a legal case, since this isn’t the first time that his tweets have been used against him in a court decision blocking his immigration order.
A lower court in Hawaii that blocked the most recent version of the order, in the case that led to the current ruling by the court of appeal, also cited tweets from the president, as did an earlier 9th Circuit decision on the previous version.