David Davis is a former Brexit Secretary, and is MP for Haltemprice and Howden

After the terrible terrorist events of 7/7 2005 that murdered 52 innocent people, there was a statement in Parliament by Charles Clarke, the then Home Secretary. It fell to me to respond on behalf of the Opposition.

Needless to say, given the enormity of the tragedy, that response was very sober. It was also very careful. The previous year there had been a similar mass murder in the Madrid railway station bombings, during the closing stages of the Spanish general election. The Spanish government fell, and Spain withdrew from any involvement in the war in Iraq. From the terrorists’ point of view it was a success.

In the ensuing year, the Conservative Opposition had been haunted by the fear that a similar attack would happen in Britain during our own general election in 2005. We determined that whatever happened we would not allow the country to be divided by such an attack, because if we did no Western election would be safe from terrorist attacks designed to influence the outcome. Whatever the temptation, we would not attack the Government, or the agencies, or the police. And although the atrocity did not come during the 2005 election, but shortly after, we stuck to the same rules.

As a result, the public debate in the ensuing weeks was measured and analytical, and the country’s political class was remarkably unified – as it had been, to be fair, during the Falklands war.  Eventually, the unity broke down when Tony Blair started using the fear of terrorism to justify ludicrously authoritarian measures such as 90 days detention without charge, but by then the risk of giving a victory to the terrorists had abated.

When I appeared on the Andrew Marr programme in 2017, hours after the first London Bridge attack, I hoped, but did not necessarily expect, that we would show the same political unity in the face of a barbaric attack. Right enough, within the hour the Labour spokesperson was blaming the murders on shortages of police – even though the police response time was extraordinarily fast, From the first emergency call to the death of the final terrorist was eight minutes. It could not have been much faster if we had armed police on every city block.

We have had the same claim this time. And the police response time on this occasion was five minutes. Whatever the merits of a larger national police force – and Boris Johnson has notably favoured sharp increases for some time – this terrible incident was not caused by shortage of police, and could not have been prevented by many more police. I am afraid that the Labour Party’s response to this has been a desperate search for an attack line on the government, rather than a search for an answer to the problem.

The real risk in this is that the desperate struggle for political advantage will suppress and confuse the cool-headed analysis that we need to deploy if we are to produce the solutions that we owe it to the next potential victims to find.

Firstly, let us look at the detailed case of Usman Khan. A confessed would-be terrorist, he was originally sentenced to an indeterminate jail term, only to be released when he was no longer a risk to the public – by means of an Imprisonment for Public Protection Sentence (IPP).

That sentence was struck down in the Court of Appeal by judges Leveson, Mitting and Sweeney. On this occasion, and as events showed, the lower court was right and the higher court was wrong. Had the lower court prevailed, the likelihood is that Khan’s two murdered victims would be alive today. And had it happened more recently, the Conservative changes to the automatic release laws would have at least kept him in longer, and involved the probation service in reviewing his release, which the Blair-era early release laws did not. But even that is not enough.

So what to do? Well, on this occasion government and Parliament must limit the discretion of judges in cases where there is a proven and ongoing risk to the public. This is no small thing. There are many who believe, in the words of the Howard League: “It is wrong to imprison someone not for what they had done but for what they might do.” Nevertheless, with a certain class of convicted criminal, ranging from terrorists to perpetrators of extreme violence, that is precisely what public safety requires.

But that runs into another problem. Between 2007 and 2012 a variety of courts, from the Queens bench to the European Court of Human Rights have challenged the validity of indeterminate sentences designed to protect the public. This appears to be why the Cameron government in 2012 suspending the use of IPPs for new cases.

Now I yield to no one in my defence of human rights and rule of law, but the European Court of Human Rights sometimes gets it wrong. On a much more mundane level, they got it wrong on prisoner votes. They also got it wrong on this.

Neither have they been particularly consistent. The two lead terrorists in the Madrid bombing were sentenced to 42,922 years each. Now clearly that sentence was more symbolic than real, but they’re not expected to be released until 2044, by which time they will be too old and frail to be any threat to the public. I’m not aware of their sentences being challenged by the European Court.

The answer is not to abandon the European Convention and the European Court of human rights, as some strident voices would have us do. You do not defeat terrorist barbarism by becoming less civilised yourself.

The answer lies in the fact that when the European Court gets these issues wrong, we should make use of the fact that if government and Parliament agree, there is nothing the court can do to insist on its decision.

This is demonstrated in the banal case of prisoner votes. It would be much more powerful when the court’s misjudgement puts British lives at risk. Indeed, it is an implicit recognition of this principle that led to the carveout for issues or fundamental national security, where the court has little purchase.

Such an approach would allow us to ensure that any future Usman Khan is unlikely to be released on the streets to kill innocent citizens. Alone, it would not be enough: we need much more in terms of anti-radicalisation measures than any government in our history has managed, whether it is on the streets or in our prisons. But first we must rejig our laws in such a way that we retain our civilised values whilst providing proper security to our citizens.

And before we do that we need to approach this problem as a nation – not as disputing political parties. Because such disputes will, in the end, please only the terrorists.