Theresa May has an enormous Trump-shaped problem on her hands. Outside Downing Street tonight and in protests across the country, people will demand that she rescind her invitation of a state visit for the new US president. A petition demanding that the visit be downgraded is around the million signatures mark as this article was written. It needed just 100,000 to be considered for a debate in parliament.

This visit is now an albatross around the prime minister's neck. But why? There was no mention of a state visit before her trip to the US. No-one was calling for it. But when she and Trump strode out for a press conference on Friday, she made herself a hostage of fortune. Not for the first time, she has invented a problem which is not in her power to control.

"I have today been able to convey her majesty the Queen's hope that president Trump and the first lady would pay a state visit to the United Kingdom later this year," she said on stage.

It was baffling. Up until then, May seemed to be doing relatively well. She had issued warnings to Republicans on Trumpism, highlighting dangers around Nato, Russia, Islamophobia and free trade. 

And then she invited him on a state visit, one of the greatest honours she can bestow and a sign of the British establishment's full embrace of the president. Britain has placed trade over principles many times before, and specifically in this manner. President Xi Jinping of China was given a state visit in 2015, much to the horror of human rights groups. He wandered round the country looking unimpressed while David Cameron, with pathetic eagerness, encouraged him to drink pints in a country pub. But at least that visit simply involved ignoring the long-established abuses in a state over which we realistically have little influence. Here, May was validating the path of a country over which we do have some influence as it embarked on an experiment in right-wing authoritarianism.

And not only that, but she was putting the royal family in Trump's orbit. Instantly stories started circulating that Trump would publicly disrespect Prince Charles because – shock horror – he believes in climate change. Princess William and Harry would have to sit with a man who boasted that he could have slept with – sorry, "could've nailed" – their mother, months after she died.

It also constitutes a likely security risk to the UK. When May was home secretary she regularly blocked entry to Britain to anyone who might encourage or lead to violence. Well she may not be able to block Trump, but by associating the British establishment with the US president’s explicit Islamophobia she complements the narrative put out by Isis to those in the UK who they hope will listen.

We know why she did it. Brexit. The newfound desperation and weakness of a country which we were assured was suddenly going to be in control of its destiny, but is in fact adrift in the sea, urgently in need of assistance from friends and allies.

But what did May secure in exchange for this offer? As far as we can tell, nothing. Trump does not seem to have made the Nato assurances she wanted. A trade deal with the US remains years away. She has nothing.

But she did create a new problem for herself. Almost as soon as she left the US the nightmare began. Trump's Muslim ban came into force in the most brutal way imaginable, penning people in airports, detaining refugees and interpreters and families and old women, and expanding to include those who had been legally resident in the US for years on green cards. It affected Brits too. Initially it seemed those with dual passports would be affected, then even those who were born in the list of banned states, regardless of their passport. This included figures like Olympics star Sir Mo Farah and Tory MP Nadhim Zahawi.

US officials have now belatedly said Brits are excluded from that. They do so like any tinpot dictatorship, coming out with a badly defined law, enforcing it aggressively, and then making exceptions based on little more than friendship or convenience, without due process. But regardless, the assurances have been made.

May's initial response was to repeatedly say that "the United States is responsible for the United States' policy on refugees". Once again, she retreats into meaningless tautology or truism when confronted with a thorny issue. It is not a tactic which fools anyone. Then her position gradually disintegrated. A panicked statement released around midnight on Saturday expressed more criticism. By the end of Sunday the US had offered assurances to the UK – although not for dual-passport holders travelling from the banned countries – and apparently all was well again.

Except that many figures in British politics are principled enough to understand that the policy is intolerable regardless of whether it affects British citizens. It is a moral and constitutional atrocity. That's not because of its effect, but because of its intention. Regardless of their failure or the damage they cause, western policy is always at least trying to solve a problem. Even the disaster of Iraq, or Guantanamo, or extra-judicial killing through drone strikes, had a purpose which, for many – including myself – they sacrificed too many moral principles to secure. But this was different. This was not intended to be effective. It catches too many and excludes too many to be a viable counter-terror policy. It is intended to be discriminatory. Nothing more. This is the theatre of prejudice, weaponised to consolidate Trump's base of support.

For many that was enough, There was now criticism of May's decision to grant Trump a state visit across the political divide. It was so serious even Jeremy Corbyn bothered to say something. The Lib Dems, the SNP and the Greens joined in. And Tory MPs made themselves clear. Sarah Wollaston said Trump should be disinvited from addressing the Houses of Parliament. James Cleverly branded the ban  "indefensible, unworkable and almost certainly unconstitutional". Tim Loughton called it "unsustainable and counter-productive". Alistair Burt suggested the UK "try and find a reason for why this visit should not go ahead".

But for now, she's lumped with it: a significant symbolic battle in which Brits appalled by Trump have an outlet for their anger. And all for what? Nothing.

What's concerning is how similarly her misjudgements in this matter correspond to those over Brexit. No-one was talking about the European Court of Justice apart from a few blow-hards when she made her October conference speech. Now it is a red line, which radically complicates her options for the Brexit deal. When she inevitably has to secure an interim period to negotiate a trade deal in 2019, continuing to come under the court's jurisdiction will be a likely EU demand and a way of securing an agreement, because of continued equivalence. But that means she'll be breaking the promises she chose to make on a subject no-one was talking about. It's a rod she made for her own back. And now she's done it again.

These unforced errors she keeps making are bad enough in their own right. But they are particularly concerning given she is about to begin the most complicated, important and dangerous negotiations of Britain's post-war history. And they are particularly depressing when they prevent the UK expressing alarm at the moral disintegration of its greatest ally.

Ian Dunt is the editor of His book – Brexit: What The Hell Happens Now? – is out now from Canbury Press.

The opinions in's Comment and Analysis section are those of the author and are no reflection of the views of the website or its owners.