Image copyright Getty Images

In four months the UK is set to leave the EU but nobody in Westminster is sure how.

Parliament has seen plenty of drama during its tortured relationship with Europe but the House of Commons has never looked more fractured than it does on the brink of departure.

Some MPs want to stay in the EU while others seem relaxed about leaving with no deal at all.

Some want the UK to be bound as closely as possible to the continent's economy while others would be content with much looser ties.

The draft withdrawal agreement the prime minister intends to put before MPs soon has been rubbished by people in all parties, including her own.

The only certainty is that, somehow, Parliament must decide what happens next. Just as it did in October 1971 when another Conservative prime minister with a meagre majority and a divided party presented his Europe deal to MPs.

And now, as then, a free vote of MPs - where they can vote with their conscience rather than following the orders of party bosses - could be the only way to unlock a Commons majority for a deal.

Europe was almost a religion for Edward Heath, whose driving political ambition was to take Britain into what was then the six-member European Economic Community.

After becoming prime minister in 1970, he quickly set about winning over the French (who had vetoed British membership twice before) and negotiating the terms of entry with Brussels.

However, with a slim Commons majority of around 30 and many anti-EEC Tories in his own ranks, there was no guarantee Heath could get his deal through the Commons.

Image copyright Getty Images Image caption David Owen - then a Labour MP - was among the rebels

Even though the then Labour leader Harold Wilson had submitted the UK's application for membership only four years before, now back in opposition Wilson set his own divided party against the deal Heath had negotiated, claiming the terms were not good enough and that the government had no mandate for a decision so big.

But within Labour's ranks were dozens of pro-European MPs, including the deputy leader Roy Jenkins, and it was clear the Conservative government would need their support to counter-balance the Tory rebels. The question was how to lure them across.

The six-day debate about the terms of entry was scheduled for the end of October 1971.

It was dubbed the Great Debate at the time and the official record reveals a Parliament grappling with the impact of entry on sovereignty and Britain's place in the world (as well as the effect on food prices, farming and fishing).

Unlike today, there was a broad consensus in the Commons that joining the EEC was a sensible and pragmatic move, but with the Labour front bench imposing a three line whip against entry harnessing that view would be difficult.

On October 11, Heath was interviewed by Robin Day on the BBC's Panorama programme and the prime minister (a former Tory Chief Whip himself) seemed strongly opposed to the idea of relaxing the mechanism for enforcing party discipline in parliament that would be required for a free vote.

"Every government is entitled to ask its own supporters to support it on a major issue such as this. You can't argue it isn't a major issue," he growled at Day.

Image copyright Getty Images Image caption Edward Heath and Robin Day in a 1969 encounter

But the team of Tory whips, which included a young Ken Clarke, knew a free vote of their own MPs could prove a decisive tactical move.

"Ted had to be persuaded by his chief whip Francis Pym to allow a free vote of Tory MPs because that was the only way that the "Jenkinsites" could justify defying a Labour three line whip so it was not a betrayal of the cause," Clarke told me.

The logic was a free vote of Conservative MPs would take the heat out of the issue and stop it being a vote of confidence in the government.

One of the Labour rebels was then Labour MP David Owen.

"It was typical Heath," Lord Owen says now.

"No sensitivity at all to the House of Commons. No sensitivity that this was an issue which you should try to carry through with all Members of Parliament.

"And exactly the same thing is being done by Theresa May now."

Lord Owen is now a Brexiteer. Ken Clarke is certainly not. But they both agree the only way a withdrawal deal can pass the Commons is for a cross-party majority to be found.

According to Clarke, the Europe issue has divided both main parties since the debate first broke out and it's absurd to pretend otherwise.

"Both parties are shattered into fractions," he says.

How the numbers stack up for May

As things currently stand, there seems to be a majority in the House of Commons against Theresa May's proposed EU withdrawal deal, according to the BBC's senior elections and political analyst Peter Barnes.

On the eve of the debate in 1971, Edward Heath was persuaded by his whips to allow a free vote of Tory MPs.

Although 39 Conservative MPs did oppose EEC entry at the Commons vote on 28 October, 69 Labour MPs voted for Europe and another 20 abstained, giving Heath's government a majority of 112, far exceeding most predictions.

For MPs on both sides of the debate it was a once-in-a-generation vote that forced them to juggle considerations of personal judgment, party loyalty and the views of their voters - precisely the same pressures that will be on MPs' minds this winter.

There are differences of course.

Today, a referendum result looms over MPs - it didn't then. A referendum on whether Britain should stay in the EEC, as it was then called, followed in 1975.

Image caption Jeremy Thorpe, Ted Heath, Roy Jenkins and Labour peer Lord Harris campaigned to keep Britain in Europe in 1975

There was then a binary choice between in or out.

Today, a number of scenarios could follow the rejection of Theresa May's deal and the politics feels far more chaotic.

Nor does it seem there are anywhere near enough potential Labour rebels to counterbalance the likely Conservative revolt.

But if the government is to have a chance of getting a withdrawal agreement passed in the teeth of opposition from Tory Brexiteers and the Labour front bench it will need to tap support from elsewhere in the Commons.

Edward Heath decided a free vote of his own MPs was the best way to that. Some in Westminster are now saying that Theresa could learn something from Ted.

Listen to '71: The Vote to go In on Monday, 19 November at 20:00 GMT on BBC Radio 4 - or after it has been broadcast on BBC Sounds.