By Jens Stoltenberg, Secretary General of the North Atlantic Treaty Organization (NATO)

Huge crowds marched in Barcelona last month. The message they sent was as powerful as it was simple. That the Spanish people will never give in to terrorism _ and that, just as their placards said, "we are not afraid".

That is a sentiment shared by people across NATO's 29 member states. In fact, acts of violence like those we saw in Barcelona and Cambrils only strengthen our collective resolve to fight terrorism, and to stand up for our open and free societies.

On July 22nd 2011, 77 innocent people in my home country of Norway lost their lives to an act of home-grown terrorism. But in the weeks that followed, as Prime Minister, I saw our society bounce back. And learned that our open and democratic way of life is stronger and more resilient than any threat we face.

In our free and open societies, it is impossible to prevent every attack. We cannot simply close down our cities. But nor should we accept terrorism as the new normal. We cannot _ and will not _ allow our values and our free societies to be undermined.

Noone says beating the terrorists will be easy. It's a global, generational challenge requiring a comprehensive, long-term solution _ with a role for our military, our intelligence services, our law enforcement agencies, our courts and our communities. As nations _ and as an Alliance _ we must remain united and strong.

As NATO Secretary General I have seen the Alliance, including Spain, play an increasingly vital role in the fight against terrorism.

We have already made significant progress. Al Qaeda is far from the force it once was, and ISIS has lost most of its territory in Iraq and Syria. But the threat is still there, and there is still much more to do.

Together, we have many tools available to us, and we must use them all.

Importantly, tackling terrorism is not only about what we do at home but also what we do beyond our borders. And, in the long run, prevention is much better than intervention.

That is why NATO remains committed to preventing Afghanistan from ever again becoming a safe haven for terrorists. At this moment, around 13,000 troops from 39 NATO and partner countries are training Afghan security forces to stabilise their country _ and in the west of Afghanistan, Spanish troops have played a key role in that effort.

While NATO's contribution to the fight against terrorism effectively began in Afghanistan, it now extends far wider. NATO is also supporting the Global Coalition to Defeat ISIS. In fact, we have stepped up the contribution of our AWACS surveillance planes, which are helping to give the Coalition a better picture of the situation in the air. NATO is also training Iraqi security forces to make them more effective in the fight against ISIS, and Spanish military instructors have supported that effort. Just a few weeks ago, Iraqi troops, trained by NATO and Allies, were putting their skills to use in the battle for Mosul.

At the same time, we are increasing our support for partners across the Middle East and North Africa, including by providing a range of training and defence programmes in countries such as Jordan and Tunisia, and preparing to help Libya rebuild its security institutions.

We are working to improve our situational awareness and the way we share information so that Allies can take swift action against the threats we face, including terrorism. This is one of the main purposes of our new Intelligence Division at NATO and the new Hub for the South we are setting up at our Joint Force Command in Naples.

We are also strengthening ties with the European Union and United Nations. Both organisations' counterterrorism capabilities complement our own. And we are working hard throughout the alliance to make our societies more resilient to attack.

Terrorism affects every NATO ally. It presents a real threat to our values, freedom and way of life. But, in the long term, we will defeat it. Because our values are stronger. Because freedom, democracy and open societies will always prevail over hatred, violence and intolerance. And because, like those who marched in Barcelona, "we are not afraid".

Disclaimer: This article is part of an Agencia EFE service which brings opinion-makers to its readers and relies on the contributions of diverse eminent figures, and solely reflects the opinions and points of view of its author.