By Dianne Feinstein

Originally published in the Wall Street Journal

The goal of the recent attacks directed or inspired by Islamic State on civilians in the U.S. and Europe is to create an atmosphere of fear and to intensify political tensions across the world. As the terrorist organization continues to lose ground in Iraq and Syria, it is focusing more on spreading terror abroad. Central Intelligence Agency Director John Brennan has repeatedly warned that Western countries should expect more attacks.

As Islamic State shifts its strategy, the U.S. and its allies should as well. The time has come for the North Atlantic Treaty Organization to invoke its self-defense clause so the full weight of the alliance is brought to bear against Islamic State, also known as ISIS.

Although ISIS has carried out attacks throughout the West, only seven of America’s 27 NATO allies—Belgium, Canada, Denmark, France, the Netherlands, Turkey and the U.K.—have joined the U.S. in directly attacking the group. Many other NATO countries could contribute special-operations forces, attack aircraft and surveillance assets to ongoing operations, thereby multiplying the effect.

Coalition forces—including Iraqi Security Forces and Syrian resistance groups backed by airpower and special-operations forces from the U.S. and other nations—have already had some success in fighting the Islamic State “caliphate” in Iraq and Syria. This coalition has retaken about a third of the territory controlled by Islamic State and liberated a dozen significant cities this year. ISIS has between 18,000 and 22,000 fighters today, down from a peak of 33,000 in 2015, according to the Obama administration.

Despite these gains, ISIS remains a significant threat to the West. At least 5,000 individuals have traveled from Europe to fight in Iraq and Syria, according to a 2015 report from the Soufan Group. Media reports suggest that as many as 10% of them have returned home. Meantime, ISIS affiliates are appearing around the world in countries as far away as the Philippines and Bangladesh. Many more are inspired by the group’s message, often propagated through encrypted online chats, to carry out “lone wolf” attacks in the West.

Over the past two years, the Justice Department has brought charges against 100 individuals in the U.S. in connection with Islamic State and has obtained 46 convictions. The Federal Bureau of Investigation has active investigations in all 50 states, and FBI Director James Comey said last year that law-enforcement agencies have more than 900 active investigations against individuals suspected of supporting the group.

Yet the effort to maintain this momentum in the fight against Islamic State suffers from an inherent conflict. Americans don’t want another prolonged war with thousands of service members deployed in combat operations, but the U.S.’s current strategy of airstrikes and limited assistance to on-the-ground partners isn’t enough to defeat the terrorists. It is now time to recognize that an increased U.S. presence, acting with NATO countries and other partners, could enhance the effort to eliminate Islamic State.

Creating a NATO rapid-reaction force to serve as an attack force against Islamic State would make a major impact. NATO countries have advanced capabilities in intelligence, airpower, special operations and other areas that are required to combat terrorists. Bringing the many resources of NATO nations to bear in the fight against Islamic State—and taking the fight to Iraq and Syria—would help to eliminate ISIS safe havens and to stanch the flow of refugees into Turkey and Europe.

Eliminating Islamic State’s hold on Raqqa and Mosul is essential. If successful, this would reduce the organization’s ability to raise funds, plan terror operations abroad and attract individuals from all over the globe.

Once the strongholds have fallen, the U.S. and other members of the anti-Islamic State coalition must continue to pool resources to support local forces in their efforts to hold those areas. Otherwise, the cities could easily fall again.

The U.S. must also be a leader in removing the online propaganda that motivates attackers to strap bombs to their chests and spray crowds of innocent civilians with gunfire. Some social-media companies are already acting on their own to take down propaganda when they see it, but more must be done. I proposed legislation in December 2015 that would require internet companies to report terrorist activity they encounter online to law enforcement agencies, so that the authorities can quickly act on such leads.

Terrorism was around before al Qaeda and Islamic State and it will be around long after both groups have been defeated. But by doubling down in the fight against these terrorist groups now, the U.S., our NATO partners, and other allies will help stabilize the Middle East while making Americans and the rest of the world safer at home.

Ms. Feinstein, a Democrat from California, is vice chairman of the Senate Intelligence Committee.