The past week has seen an alarming campaign of slaughter unleashed by the militants of the Islamic State, hitting targets in four different countries. (Jason Aldag,Ishaan Tharoor/The Washington Post)

In the global revulsion at the past week’s terror attacks in four Muslim countries, the United States and its allies have a new opportunity to build a unified command against the Islamic State and other extremists. But as the U.S. seeks to broaden this counter-terrorism alliance, it should be careful about partnering with Russia — unless Moscow distances itself from a Syrian regime that many Sunni Muslims despise.

The savage attacks in Turkey, Bangladesh, Iraq and Saudi Arabia should convince Muslim nations and the West that they share a common enemy in extremist groups such as the Islamic State. What they need now is a shared command-and-control structure, like what the U.S. and Britain forged in December 1941, after the shock of Pearl Harbor. Merging military and intelligence resources wasn’t easy, even for longstanding partners in Washington and London. But Prime Minister Winston Churchill knew that once America had fully joined the battle, the allies’ eventual victory was certain.

Similar confidence would be inspired by a command structure that truly fuses the resources of the U.S., Europe, Turkey, Iraq, Saudi Arabia, Indonesia, Pakistan and the many other nations that have been targeted by Islamic State terrorists.

A sign of how unpopular these attacks are with Muslims is that the Islamic State isn’t taking credit for the attacks in Turkey and Saudi Arabia — even though it’s widely seen as the likely perpetrator — and that other Islamist groups are condemning the violence, especially the bombing in the holy city of Medina.

Muslim worshippers gather after a suicide bomber detonated a device near the security headquarters of the Prophet’s Mosque in Medina, Saudi Arabia, July 4, 2016. (REUTERS/Handout)

On Tuesday the SITE Intelligence Group gathered some of the online ripostes from rivals of the Islamic State. An Australian cleric named Abu Sulayman, who is a member of Al Qaeda affiliate Jabhat al-Nusra, tweeted: “The #MedinaBlast is a criminal act that Muslims must condemn.” Another pro-Al Qaeda account tweeted: “[I]f ISIS is not behind the attacks in Istanbul and Medina they should deny their involvement.”

Saudi Arabia had a similar wake-up call several years after Sept. 11, 2001, when the kingdom’s leaders realized that Al Qaeda terrorists were targeting the House of Saud, too. That led to joint operations against Al Qaeda by the kingdom’s counter-terrorism service and the CIA. Monday’s attacks in Medina, Jeddah and Qatif should deepen that cooperation—and draw in other Arab partners, such as Jordan, Egypt, Morocco and the United Arab Emirates.

A number of countries were the target of serious terrorist attacks in the last week, including Iraq, where a car bomb in a Baghdad shopping district killed at least 187 people. (Deirdra O'Regan/The Washington Post)

The U.S. has a chance to hit the “restart” button with Turkey, too. Turkish President Recep Tayyip Erdogan has been straddling the issue — condemning the Islamic State but failing to close his border with Syria because of pique over U.S. support for Syrian Kurdish fighters. Now that Erdogan can see the jihadist dagger at his throat, he should want closer military and intelligence links with Washington. He should also think about reopening negotiations with the Kurdish Workers Party, or PKK, so that he’s not fighting a two-front war against terror.

What about Russia? Should Moscow and Washington join forces against terrorism? On one level the answer is obviously yes. Foreign fighters have been streaming from Russia and its former republics to join the Islamic State. Two of the three attackers in Istanbul appear to have been Russians. Real cooperation would be useful, so long as it doesn’t condone and reinforce Russian bad behavior.

Syria is the test case: The Russians have been asking the U.S. for months to share targeting information about Islamic State and Jabhat al-Nusra positions in Syria, so that Russian forces can attack the jihadists and avoid hitting groups that, in theory, are working with the U.S.

The Obama administration is now debating whether to endorse such Russian-American sharing of targeting intelligence. The U.S. military, seeing aggressive Russian behavior in Europe, is wary. Administration officials who favor cooperation argue that it should come with a warning — that if Syrian forces continue bombing U.S.-backed opposition groups, the U.S. will strike back against the Syrians and take their jets out of the sky.

If Russia accepts such a real limitation on President Bashar al-Assad, then it should join the team. But if it continues unlimited support for Assad, Russia will only fuel the jihadists’ rage — and complicate American efforts to build a broader, unified command.

The terrorists who struck Istanbul, Dhaka, Baghdad and Medina made a potentially disastrous mistake. It may not look that way, after last week’s encounter with the metastasizing virus of the Islamic State. But the real goal of the jihadists has been to divide Muslims and the West. If the U.S. offers strong leadership now, it can repair that breach — and help organize a military and intelligence alliance against a common threat.