In happier times, Theresa May won positive “Maggie May” headlines in right-wing newspapers when they favourably compared her to Margaret Thatcher. Today, there is a more ominous parallel. May’s perilous position over her Brexit deal reminds me of the atmosphere at Westminster before Thatcher was pushed out of Downing Street by her own party in 1990.

In both cases, a Conservative prime minister was seen by her MPs as remote, untrustworthy, “not straight”, unwilling to listen in meetings with ministers and backbenchers, and utterly determined to plough on with unpopular policies in order to avoid the dreaded “U-turn” headline. The case for the defence would rightly point to a stamina, courage and resilience lacking in most men.

Both leaders suffered a stream of resignations by ministers, after clashes over policy and a dictatorial style relying on a tight inner circle. There was a febrile atmosphere at Westminster amid frenzied speculation about a leadership challenge. Both prime ministers went on a pretty pointless foreign trip – Thatcher to a security conference in Paris attended by world leaders, May to last week’s G20 summit in Argentina – when they should have been wooing their MPs ahead of a crucial vote.

Not everything is the same. Thatcher had been in power for 11 years with big majorities, while May has been in office for two and a half years, the last 18 months without a majority after throwing it away last year. Their crunch votes are different. Thatcher was fighting for her political life after failing to beat Michael Heseltine by a sufficient margin in the first round of a Tory leadership election. When the result was read out, I was in a scrum of journalists in a heaving Commons committee corridor. We knew instantly that Thatcher was finished; she had won, but lost, because some Tory MPs would now switch to Heseltine in round two.

She vowed to fight on. But when she summoned cabinet ministers for one-to-one sessions, they told her, reciting a pre-arranged script, that they would support her but she would lose. “Treachery with a smile on its face,” said Thatcher, who resigned the following morning. It was an act of regicide against a leader who had won three general elections and, for better or worse, had transformed the country. “What have we done?” shell-shocked Tory MPs kept saying to me.

May’s big vote, on her Brexit deal, will be in the Commons chamber next Tuesday evening. Again, a frenzied atmosphere will build at Westminster during the day. If she loses, as everyone expects, Tory MPs will probably force a vote of no confidence in her as party leader. (Tory rules have changed since 1990; if May loses such a confidence vote, she will have to resign, without the same opportunity as Thatcher to stand in the ensuing leadership election).

For both prime ministers, the Europe issue was at the heart of their troubles, although Thatcher’s intransigence over the poll tax convinced many Tories she could not win another general election. Europe felled the last three Tory prime ministers – Thatcher, John Major and David Cameron. It could soon bring down May, her career killed by Cameron’s poisonous legacy.

One lesson from 1990: it might look like backbenchers matter the most, but the cabinet is often pivotal. Of course, they both matter; some of Thatcher’s ministers, such as Kenneth Clarke, insist the cabinet was merely reflecting the views of her MPs.

If the 100 or so Tory MPs who have criticised May’s deal vote against it, she would lose by almost 200 votes and, along with her agreement, would surely be finished. But I suspect the rebellion will be much smaller. If we are in a grey area, what the cabinet does will be very important.

Support free-thinking journalism and attend Independent events

It was revealing that May held an unscheduled meeting with loyalist ministers on Thursday, where some urged her to delay Tuesday’s vote. She refused, although it could yet be postponed if government whips tell her on Monday she is heading for a humiliating defeat. When cabinet members asked May for her Plan B if she loses, she was characteristically sphinx-like, leaving her ministers exasperated. Similarly, backbenchers she has met this week grumbled afterwards that she was “not listening”. Another flashback to Thatcher. May, too, may find that her fate lies in her cabinet’s hands.

She would be wise to work out her Plan B, and ensure the cabinet will support it, before Tuesday. Or, like Thatcher, she might discover that “loyalist ministers” are less loyal than she thought, especially those eyeing up her job.