Theresa May shouldn’t get too carried away with the unexpected round of applause she won at the EU leaders’ summit last night for securing a stage one Brexit deal. Yes, the plaudits recognised her true grit during difficult negotiations, notably during last week’s wobble when the Democratic Unionist Party’s initial veto could have scuppered the deal and ended her premiership.

But the backslapping was also a recognition by the EU27 of May’s troubles at home. As one Brussels insider told me: “There is concern at how weak she is domestically. No one here wants to see the collapse of the Government.”

Other leaders fear May would be replaced by a hardline Brexiteer such as Boris Johnson. He is still remembered in Brussels as the man who, as The Daily Telegraph’s man there, produced what was seen as a barrage of anti-EU propaganda which helped to poison UK opinion about the EU.

Some of the Prime Minister’s domestic problems are self-inflicted. Take Wednesday’s embarrassing Commons defeat, when MPs insisted on passing a law to approve the Brexit deal before ministers start implementing it.

Parliament was right to stand up to May on Brexit. There was always going to be a moment when it did. Wednesday’s vote makes a cliff-edge, no-deal Brexit much less likely. A soft Brexit is not inevitable, but more likely. That is what the pro-European Tory rebels want, to limit the economic damage. They are not the wreckers, saboteurs and traitors portrayed by the Brexit press and Tory Eurosceptics, who have conveniently forgotten their pledges in the referendum that leaving the EU would restore sovereignty to Parliament.

May should learn an important lesson from her setback. For a start, she should withdraw her silly proposal to write into law the exit date of 29 March 2019, which faces defeat by the same coalition of pro-EU Tories and opposition parties next Wednesday. What if negotiations go up to the wire and the DUP stage a last-minute stunt on 28 March? May would not enjoy the extra five days she needed last week to get the phase one deal back on track. The March 2019 deadline is very ambitious. A tactical retreat now would be less damaging than another Commons defeat. Although Downing Street today refused to back down, I suspect common sense will prevail.

The other lesson May should learn is that she needs to build bridges with the pro-EU Tories. Since becoming Prime Minister, she has pandered to the hardline Brexiteers; she precipitately ruled out single market and customs union membership and a remit for the European Court of Justice without thinking through the consequences, which have now become apparent during the negotiations.

May allies complain that pro and anti-EU factions are still refighting the referendum. But she essentially backed one side, spurning the opportunity to bring her party together. That’s partly why Wednesday’s rebellion happened and why there has been so much bitterness between the two Tory tribes since.

May should embrace rather than fight the majority for soft Brexit in Parliament which emerged this week. The 60 Tory hardliners might threaten to topple her, but there are 316 Tory MPs, so she could survive a vote of confidence as party leader by rallying mainstream MPs behind soft Brexit. If she tries to sideline Parliament and railroad through a hard Brexit, she will not unite her party or the country and her deal will not stick.