In Belfast three weeks ago we celebrated the 20th anniversary of the Good Friday agreement, which ended political violence in Northern Ireland for good. Today in the small town of Cambo-les-Bains, in the Basque part of France, some of us who were involved in Northern Ireland will participate in an international gathering to mark the permanent end of Eta.

Eta issued a statement this week wrapping up the organisation for good after more than 40 years of violence, in which hundreds of lives were lost and thousands of people were injured.

Basque separatist group Eta announces dissolution Read more

It is hard to remember now just how bloody the terrorist campaigns were in Northern Ireland and in the Basque country – with news of fresh deaths and injury every week and sometimes every day.

Eta’s statement is something to celebrate. It marks the end of the last violent conflict in Europe, and the last armed group. But it should also be an occasion to draw lessons. There are plenty of other violent conflicts around the world, and we should not be complacent about the danger of such violence returning to Europe unless we take the correct steps to prevent it.

The Spanish government may well claim that the conflict was ended by tough security measures alone. And there is no doubt that is part of the story. In the Basque country, as in Northern Ireland, the success of the police, the army and the intelligence agencies certainly played a key role. But it is equally important to understand that it is not the whole story. If these groups enjoy political support it is very unlikely they can be defeated by purely military means. If there is a political problem at the heart of the conflict then there will need to be a political solution that requires dialogue.

If John Major had not been willing to engage in a secret correspondence with Martin McGuinness even as the IRA bombing campaign continued in Northern Ireland and on the British mainland, there would have been no peace. And if successive governments in Spain had not engaged with Eta – while publicly denying they were doing so – then Eta would not have finally disbanded.

Play Video 0:48 ’A slap in the face’ for Madrid: Puigdemont hails Catalonia election win – video

In 2004 the Socialist government of José Luis Rodríguez Zapatero engaged in a secret dialogue with Eta. Sadly the agreements they reached in 2005 and 2006 collapsed when both sides failed to implement their promises. But, as in Northern Ireland, eventual success was built on a series of failures. Patient work, particularly by the political leaders of the independent-ist left in the Basque country, helped lead to the Aiete declaration in 2011. In response to an appeal by a series of international figures, headed by the former UN secretary general Kofi Annan, Eta announced it would end its armed campaign. The guns have remained silent ever since.

The election of a conservative government in Spain that year brought an end to the engagement, and made it much harder to deal with the remaining issues left over by the conflict – including the guns, the prisoners, the exiles and, above all, the need for reconciliation. Even in opposition, the People’s party (PP) had tried to complicate Zapatero’s negotiations as much as it could, by mounting a campaign of crispación, or “tension”, around the peace process, and in government the PP leader, Mariano Rajoy, ended contacts with Eta. We in Britain had a much easier time in negotiating because of the bipartisan approach under which both Labour and the Conservatives supported each other’s efforts to make peace.

Even in the face of the opposition of the PP government, however, it was possible to decommission all Eta’s weapons – over three and a half tonnes of them – with the help of international monitors last year. And a few weeks ago the group issued a statement in which it came as close to an apology to the victims of its violence as I have ever seen from such an organisation, even if it was not enough to satisfy some of the victims.

The risk of the government’s approach in Catalonia is that it could tip us into another period of political violence

Today is the final page of the final chapter of political violence in the Basque country. In my view the right lesson to draw from the lengthy process that brought us to this point is that unless you combine effective security and intelligence pressure with dialogue, you are unlikely to solve the problem.

The same applies to starting conflicts. The risk of the Spanish government’s approach in Catalonia is that it could tip us into another period of political violence just as the Basque one ends. So far, thank goodness, it has remained remarkably peaceful. But if the policy tools used to deal with the crisis are just imprisonment, heavy-handed policing and imposing direct rule from Madrid, there is a risk. And without attempts to open a political dialogue with the pro-independence forces there, there will be no political solution.

Rajoy’s dilemma is a painful one. He is outflanked by an even more radical party, Ciudadanos, and the right wing of his own, which is completely opposed to negotiation. But sometimes political courage is required if a conflict is to be avoided. It is possible that there could have been an agreement in Northern Ireland in 1973 at Sunningdale, if the loyalists and Sinn Féin had been included. But they weren’t, and we suffered 30 more years of bloodshed on our streets before we reached the Good Friday agreement – a pact described by Seamus Mallon, the moderate Catholic SDLP deputy leader at the time, as “Sunningdale for slow learners”.

I hope today’s events in Cambo-les-Bains act as a lesson for political leaders in Europe and elsewhere. There is a way to end and to avoid armed conflicts. It requires strong leadership, patience and a willingness to talk to your enemies.

• Jonathan Powell was chief British negotiator on Northern Ireland from 1997 to 2007