What on Earth is wrong with Donald Trump? Did he actually set out to lose his immigration ban in the appeals court deliberately, so that he could whip up his base into ever more fury at the “elites”?

Contrary to what you may hear, the U.S. Court of Appeals for the 9th Circuit on Thursday did not — repeat: did not — repudiate Trump’s legal right to suspend selective immigration. It just repudiated the bungling incompetence with which his administration made the case.

Yes, the three justices ruled: “Courts owe substantial deference to the immigration and national security policy determinations” of the president and Congress. That is “an uncontroversial principle that is well-grounded in our jurisprudence.” Indeed, as I pointed out earlier this week, it is well established that the president has very broad discretion to suspend immigration where he deems it necessary.

“ Legal precedent strongly suggests that [the judges would] support the president so long as he could reassure them he had a rational basis for his action. ”

But that was not what the Trump administration claimed. Instead, they argued that they were actually above the law, the Constitution or legal review.

“The Government has taken the position that the President’s decisions about immigration policy, particularly when motivated by national security concerns, are unreviewable, even if those actions potentially contravene constitutional rights and protections,” the justices wrote with disbelief. They added: “There is no precedent to support this claimed unreviewability, which runs contrary to the fundamental structure of our constitutional democracy.”

You couldn’t make this up.

Trump is now raging at the judges. But the blame for this fiasco lies entirely with him, and no one else.

All the administration had to tell the appeals court was that it had rational reasons for suspending immigration from the seven specific countries. Even with national security details “redacted,” the president’s lawyer could have laid out a simple case. Call it Iraq War II. “Intelligence sources say ... intelligence sources warn ... We have received intelligence ...” And so on. He could have kept it vague and menacing. He could have made it up. So long as he offered something. All the courts needed was an excuse.

Cue our old friend “Curveball.”

The justices were very unlikely to second-guess a president’s national security intelligence. They don’t consider that to be their job, they don’t want to do it, and they know how dangerous that could be — for the country and, indeed, for the standing of the courts.

Legal precedent strongly suggests that they’d support the president so long as he could reassure them he had a rational basis for his action.

But that’s not what Trump’s lawyer did.

Trump’s travel ban loses in court: What happens next?

Instead, August Flentje, a lawyer for the Trump administration, spent most of the hearing arguing the president’s actions were beyond review — and that individual states had no “legal standing” to challenge his executive order either. That was another stupid and fruitless argument, especially as Washington, the state in question, had shown clearly how it was affected.

Trump’s refusal to offer any kind of rational excuse for his immigration ban produced a double whammy. First, it insulted the judges by saying they had no right to review his actions. Second, it left him wide open to a First Amendment challenge. As the judges noted, there was plenty of Trump administration rhetoric suggesting this might be an unconstitutional ban on Muslims. Trump’s refusal to offer an alternative, rational explanation for the executive order was therefore a real problem.

But maybe none of this should be a surprise.

What should we expect from a president whose special counselor hawks Trump family merchandise from the White House podium, and whose chief of staff recently heralded the arrival of our “new King”?

I’ve gone blue in the face over the past 20 months reminding MarketWatch readers that, no, Donald Trump was not a “successful businessman” or a “successful executive” in the traditional meanings of those terms. He is a serial bankrupt. He inherited a fortune from his dad, and made more only by scamming people, and sticking it to his bondholders and stockholders. Many of you would be rich, too, if you had his start, his greed,and his lack of ethics.

It would be genuinely interesting to see a true business leader take on the role of president. But Donald Trump is no Steve Jobs, no Henry Ford, no Bill Gates, no Walt Disney, no Warren Buffett. He is no value creator, no genius and no leader. He is a con artist, a huckster, the equivalent of a hawker of used cars or subprime derivatives. His skills are chutzpah, greed and a cynical, rat-like cunning.

The law still favors his ban on immigration. The question is going to be whether his administration makes a real legal argument when it goes, as it surely will, to the Supreme Court.

My original take was that Trump had merely bungled his case. But I could be wrong — very wrong.

I mean what I say about his “rat-like cunning.” Trump is a master manipulator. It is actually plausible that he screwed up this lawsuit deliberately. Trump and Trumpism thrive on conflict, paranoia and resentment. News that a bunch of “fancy-pants, elitist lawyers” at the 9th Circuit — in San Francisco, no less — has thwarted his immigration ban is great politics for him. It whips up his base into fury, and encourages them to look to him, even more, as their “protector” against the “elites.”

And, without wishing to be ghoulish, just imagine if an immigrant from one of these seven countries were by remarkable coincidence to cause a terrorist attack. Trump would look like a hero to his fans. His opponents would look terrible.

Would Trump do this deliberately? Would he play politics with people’s lives in order to consolidate his regime’s grip on power?

Well, that’s what Vladimir Putin did. And we know how much Trump admires Putin.