LONDON — No. 10 is feeling more bullish than it has in weeks.

Prime Minister Theresa May has survived the most perilous month yet in the internal Tory Party battle over what kind of Brexit it wants and, aides say, is at last close to putting the country on a trajectory towards a Brexit that keeps her Cabinet together.

Officials familiar with the government’s plan say the U.K.'s future relationship with the EU will be a long way off Leave campaigners' preferred destination of Canada-style regulatory divergence, and the U.K.'s rules will remain much closer to the rest of the bloc, a model they vociferously opposed at the end of last year.

On the face of it, the last few months have been bruising for the U.K. prime minister. Her Cabinet is split over what kind of future customs relationship Britain wants with the EU, talks in Brussels have ground to a near-halt, and, with less than a year until the U.K. must leave the European Union, time is running out to reach agreement with Brussels or risk leaving without a deal.

However, behind the scenes, May's team is more positive than they have been in weeks — and many Leave supporters say this is, in part, because they have lost ground.

May and her team believe they have found a fudge that the majority of her Cabinet can stomach — partly because some pro-Leave Tories didn’t realize what was happening.

At the beginning of May, Cabinet Brexiteers, including Foreign Secretary Boris Johnson, openly derided the prime minister’s favored "customs partnership" proposal — which would involve the U.K. collecting tariffs on the bloc's behalf to avoid a hard Irish border — and backbenchers threatened a leadership challenge should she sell them out. Come the end of the month, those same critics had swallowed the PM’s Irish border backstop, which would keep Britain inside part of the EU customs union after 2021 if no other arrangement is agreed.

“When we say ‘a deep and special partnership,’ they are not just flowery words,” said one Whitehall official, noting the whole Cabinet signed up to May's Mansion House speech earlier this year, in which she promised “U.K. and EU regulatory standards will remain substantially similar in the future.”

Of course, even if the prime minister manages to get her Cabinet to agree, she is yet to secure the backing of Brussels, where EU officials and diplomats say the U.K.'s latest proposal is dead on arrival. The U.K. parliament, too, could yet force May to change tack over customs — or something else.

But, despite all the noise, May and her team believe they have found a fudge that the majority of her Cabinet can stomach, partly because some pro-Leave Tories didn’t realize what was happening, because others came around to May's approach, and because the rest did not have a plan to stop it.

In short, Brexiteers lost control of Brexit.

Creeping pragmatism

December's agreement with the EU was the moment Leave MPs took their eyes off the ball, many now concede.

No. 10 convinced them the commitment to “full alignment” with EU regulations in the absence of agreed solutions was merely a form of words to move talks on, Brexit-backing MPs say. In reality, the December text, coupled with the abandonment of the prime minister's much-loved mantra that “no deal is better than a bad deal,” firmly set the U.K. on a path toward a close regulatory relationship with Brussels after Brexit.

Senior Downing Street aides privately agreed that walking away without a deal is not a realistic option toward the end of last year, despite May's public proclamations to the contrary, according to officials familiar with the discussions.

But as Downing Street advisers considered "no deal" to be off the table, ministers at the Department for Exiting the European Union (DExEU) still believed the U.K. could realistically walk away from talks, officials at the department said. At the turn of the year, DExEU ministers and advisers vowed to ramp up no-deal preparations, insisting this was a crucial component of the PM’s negotiating strategy with Brussels, according to officials. To their disappointment, a Cabinet minister for no deal was not appointed when the prime minister reshuffled her top team at the beginning of the year and serious contingency planning was put on the backburner. With no plan for no deal, Brexiteers lost a key plank of their leverage to secure the deal they wanted with the EU.

Leavers have since divided into two camps over what has become the significant question: Do they accept Downing Street's plan for a close-alignment deal and try to “fix” it afterward, or continue to fight for a more distant relationship between the U.K. and the rest of the EU?

In a major win, May convinced some Brexiteers they should sign up to a deal they may not love in the short term, but that gives them a chance to diverge in the years ahead, according to officials in Downing Street and allies of Leave-supporting Cabinet ministers. She warned them that not doing so would see them end up with political turmoil and the possibility of no Brexit at all. To turn a phrase, “a bad deal is better than no deal.”

Downing Street officials said this argument has placated a number of senior Tory Leavers, including prominent figures on the Vote Leave campaign such as Environment Secretary Michael Gove, and a section of the increasingly disparate European Research Group [ERG] of backbench Brexit-supporting MPs. Echoing the Downing Street line, a senior former Vote Leave campaigner said: “It has come to the point where the risks are such that we just need to get out and deal with the rest later.”

Many Leavers' have opted for pragmatism. Henry Newman, the director of the Open Europe think tank, which Monday published a paper calling for the U.K. to adopt EU rules for goods but not services, said: "Hard-line Leavers need to recognize that although the country decisively voted for Brexit, we need to recognize the concerns of roughly half the electorate who did not, and accept that there's insufficient parliamentary support for a Brexit that severs all ties with the EU."

“We can’t throw out the good in pursuit of the perfect," said Leave-supporting Tory MP Andrew Percy. "A more flexible solution on customs arrangements is in no way a betrayal of Brexit. Let's get out and then we can determine some of these other matters in the future.”

Percy also had a warning for his more hard-line Brexiteer colleagues: “The ERG are valuable contributors to the debate but they are not representative of many Brexiteer MPs like me. If they don't start to get real, they risk the collapse of the government and there is no way of telling what that might mean for the future of Brexit.”

One member of the ERG, who signed the group's letter to the prime minister in February demanding the U.K. leaves the customs union and secures “full regulatory autonomy,” said they have since changed their view. “I voted Leave and I’m a free-marketeer but I care more about stopping Corbyn getting into No. 10 [Downing Street] than I do about signing new trade deals,” the MP said.

Another former Leave campaigner said some Brexiteers could ultimately accept a form of customs union: “If you’d said when [David] Cameron gave his Bloomberg speech [when the then prime minister launched his attempted renegotiation with Brussels back in 2013] we could be out of the single market, take back control of borders but stay in a customs union, you’d have bitten their arm off.”

One last stand

However, such climbdowns have deeply depressed other Brexiteers. The uncompromising faction of the ERG increasingly now sees Brexit Secretary David Davis and Johnson as the only Cabinet Leavers sticking to its red lines.

“I expect the government to stick to the clear statements made by the prime minister and in the Conservative Party manifesto," said Jacob Rees-Mogg, chairman of the ERG. "Leaving the single market and customs union were explicit promises to be delivered in substance as well as form and large annual payments were specifically ruled out by Theresa May. I trust her to deliver on all of this otherwise we would be the most craven vassal state.”

Andrea Jenkyns, a member of the Brexit select committee who resigned from the government last month in order to keep up pressure for a hard Brexit, said the U.K. couldn't be free to trade globally if it remains within the EU's regulatory framework in some way.

“A real complacency has set in. No. 10’s argument that you can get out and then diverge later — you can’t. That’s not going to happen" — Former Cabinet minister

"A course of action that kept us in the customs union through the backdoor would be disastrous not only for our country but for our democracy," Jenkyns said. "The 17.4 million people who voted to leave would feel betrayed. And I wouldn't blame them.”

One former Cabinet minister, speaking on condition of anonymity, said: “The fact is Dominic Cummings is right,” referring to the former Vote Leave chief’s recent blog post accusing May and Tory Brexiteers of “surrender.”

“A real complacency has set in. No. 10’s argument that you can get out and then diverge later — you can’t. That’s not going to happen.”

The problem for those who subscribe to this view is they have little leverage to force May to change tack. Despite having the numbers to trigger a confidence vote that could topple the prime minister, most hard-line Brexiteers agree she would likely win the support of a majority of Tory MPs. What's more, in the event that a challenge succeeds and installs a Brexiteer in Downing Street, this faction does not have enough votes in the House of Commons to get through their vision of Brexit, and that would not change without another general election.

The December agreement, the lack of no-deal preparations and the ticking Article 50 clock — which means Britain will leave the EU on March 29, 2019, without unanimous agreement among the remaining 27 countries that the U.K. should be granted an extension — hands much of the leverage to Brussels.

Senior Leavers in the government said the U.K. is headed for a Brexit that nominally keeps the country outside the single market but binds Britain to the EU’s regulatory framework — to all intents and purposes inside a customs union and with large, ongoing payments to Brussels.

In such a scenario, the only tangible policy difference felt by British voters would be on immigration, Leavers say, with Downing Street calculating that is what the majority of those who voted for Brexit care about most.

Despite appearances, May has had a better month than she expected, but she faces one last stand from those disgruntled Brexiteers she has yet to win over.

“There is still time to rescue the position" — A Brexiteer MP

The ERG, which meets every Tuesday at 6 p.m., will lobby the prime minister to change course over the next few weeks. Discontent within DExEU is such that ministers in the department have discussed whether they can stay in post if Downing Street does not listen.

“There would be a mass walkout at junior ministerial level,” said a former Leave campaigner familiar with the discussions. “Could [Brexit ministers] Steve [Baker] and Suella [Braverman] really stay if No. 10 sells us out?”

“There is still time to rescue the position,” said one Brexiteer MP. But not that much time.

Alex Wickham is the news editor of Guido Fawkes and a columnist for GQ magazine.