The abhorrent beheading of two American journalists and a British aid worker shocked the world. So did the tragic downing of Malaysia Airlines flight MH17 over eastern Ukraine. The deaths of these innocents show the global consequences of two major crises on Europe’s doorstep: the advance of the so-called Islamic State terrorist group across Iraq and Syria, and Russia’s aggression against Ukraine. The peace and security we enjoy in Europe and North America are under threat like never before.

These challenges will last for years, and we need to face that reality.

With Russia, the North Atlantic Treaty Organization has tried long and hard to build a partnership that respects Russia’s security concerns and is based on international rules and norms. Regrettably, Russia has rejected our efforts to engage. Russia has trampled on all the rules and commitments that have kept peace in Europe and beyond since the end of the Cold War. It is now clear that Russia regards the West as an adversary, not a partner.

The terrorist threat is now growing in Syria and Iraq. The Islamic State terrorists are fueling the fire of sectarianism already burning across the Middle East and North Africa, with the risk rising that terror will be exported back to our shores.

Pro-Russia rebels in Krasnodon in eastern Ukraine, Aug. 17. Associated Press

We are confronted by forces of oppression that reject our liberal democracy and our liberal, rules-based international order. While their agendas and ideologies are different, they are virulently against the West and what we represent. They will grasp every opportunity to undermine our values of individual liberty, freedom, democracy, the rule of law and human rights.

In this age of unrest and revisionism, free societies must stand strong and united as a force for freedom. We must be prepared to act when we have to. We must work with like-minded nations. And we must show confidence in our own values.

At the NATO summit in Wales earlier this month, we strengthened our collective defense. We reaffirmed our core commitment to defend each of our 28 allies against any threat. We agreed to maintain a continuous presence in Eastern Europe and to create a spearhead force of several thousand troops that can be deployed at very short notice. We also pledged to halt the decline in defense spending and move toward investing 2% of our gross domestic product in defense over the next decade. Because freedom does not come free, and security is priceless.

Military force is rarely the only response to a crisis, but it is often an essential part of that response. I welcome President Obama’s strategy to degrade and ultimately destroy ISIS, working together with other NATO allies and partners. Should the new government in Baghdad request our assistance, NATO as an alliance stands ready to consider a defense-building mission to strengthen the ability of the Iraqi security forces to defend their own country. We could also help coordinate the provision of humanitarian aid and the air transport needed to deliver that assistance. Allied nations will also work closely together to exchange information on returning foreign fighters who can pose a threat to our countries.

Islamic State fighters in Raqqa, Syria, June 30. Associated Press

Europe and North America are at the core of the global community. Our strength does not come from military might alone, but from the strength of our democracies and our economies. We must strengthen our community of free nations by continuing to reach out to like-minded partners. We should bolster our economies through more trade and investment, creating jobs and setting a strong example for others to follow. We need an even closer partnership between the European Union and NATO and to keep the door open to new members.

Our liberal international order—embracing freedom, democracy, the market economy, common rules and norms, and renouncing territorial conquest—has brought unprecedented peace, progress and prosperity to billions of people. This has been an historic achievement. So we must stand up with greater confidence for our principles and our values.

These values are now under threat. They cannot be taken for granted. As we approach the end of over a decade of fighting in Afghanistan, there is a temptation to turn inward. But the world will not become less dangerous just because we wish it to be. Threats will not go away just because we want to look away. We must keep a global perspective and counter isolationism and retreat.

If we fail to defend democracy, forces of oppression will seize the opportunity. Because appeasement does not lead to peace. It just incites the tyrants. Failure to counter oppression will only invite further oppression. Military action will always be the last resort, but we must be able to use it when we need to. Not to wage war, but to build peace.

This is a time when our values are being challenged and our will is being tested. Keeping NATO strong and North America and Europe united has never been more important. It is the only way to preserve our freedom, protect our people, and promote our values.

Mr. Rasmussen is the secretary general of NATO.