LONDON (Reuters) - President Vladimir Putin says Russia's war in Ukraine is part of an existential struggle with the West that demands total focus - but deadly shootings in Dagestan show that militant Islam is a rising threat that may force him to redirect some of his resources.

The latest violence, in which at least 20 people were killed on Sunday evening in a series of apparently coordinated shootings in Russia's far south, raises awkward questions for its intelligence and security services.

They appear to have been caught off guard at a time when much of their attention is focused on Ukraine and the threat of Ukrainian-linked attacks inside Russia.

"Radical Islamism is again raising its head in Russia," said Sergei Markov, a former Kremlin adviser, who had just returned from a trip to the North Caucasus region.

"It is clear that there is a problem with Islamist terrorism and it is very serious. We need action from the authorities."

The reported involvement of two relatives of a local official who had held a counter-terrorism meeting as recently as April, and another attacker's past affiliation with a pro-Kremlin party, have raised fears of infiltration of the local elite.

The attacks in Derbent and Makhachkala, in which a Russian Orthodox priest and at least 15 policemen were killed and a synagogue was burned down, is a blow to Putin's long-standing pledge to the Russian people that he will ensure domestic stability.

It may also prompt a review in Moscow of the way that impoverished majority-Muslim Dagestan is run, according to some experts.

The same region, some 1,600 km (1,000 miles) south of Moscow, was rocked in October when rioters shouting "Allahu Akbar" or "God is Greatest" stormed an airport to "catch" Jewish passengers on a flight from Tel Aviv.

Dagestan is important to the military, and a naval base for Russia's "Caspian Flotilla" is being built there.

To its west lies Chechnya, also a majority-Muslim region, where Moscow has fought two wars with separatists since the 1991 collapse of the Soviet Union.

Riccardo Valle, Director of Research at The Khorasan Diary, a non-partisan centre that reports on militancy in the region, told Reuters that Islamic State and other jihadist groups had been discussing the opportunity that Russia's war in Ukraine presented for them.

He said the Ukraine war had hindered essential cooperation between Moscow and the West on tackling Islamic State, as well as diverted Russian resources, and that he Dagestan attack showed "a huge security gap in Russian intelligence-gathering".

Meanwhile, he said, jihadists had been "writing in articles about how Ukraine is the so-called 'black hole' for the West and Russia. Meaning that, while the West and Russia are focusing their attention in Ukraine, jihadists can take advantage of this situation and strike".

DAGESTAN SHOOTINGS FOLLOW CONCERT HALL ATTACK

In an attack in March claimed by Islamic State, gunmen raided the Crocus City concert hall near Moscow, killing nearly 150 people in an incident that Moscow suggested Ukraine had also had a hand in directing - an allegation Kyiv denied.

And just over a week ago, a bloody Islamic State-linked prison uprising took place in Rostov, southern Russia, in which special forces shot dead six inmates who had taken hostages.

Western military experts said Sunday's attacks looked well planned and coordinated.

There was no immediate claim of responsibility. But the Russian branch of Islamic State-Khorasan's Al-Azaim Media posted a statement praising what it called "brothers from the Caucasus" for the attack.

The Washington-based Institute for the Study of War said in a research note that Wilayat Kavkaz, the Northern Caucasus branch of Islamic State, had "likely conducted" the shootings.

The Kremlin said Putin had been following events closely and giving orders, and that an investigation was under way.

When asked by a reporter, Putin's spokesman played down fears of any return to the late 1990s and early 2000s, a period when Islamist militants launched regular attacks on civilian targets across Russia.

"Russia is different now, society is absolutely consolidated. And such criminal terrorist manifestations as we saw in Dagestan yesterday are not supported by society, either in Russia itself or in Dagestan," Dmitry Peskov said.

Sergei Melikov, head of the Dagestan region, called the attacks an attempt to destabilise society.

The United States gave Russia advance warning of the Moscow concert hall attack in March, but the Kremlin has insisted that it has not taken its eye off the ball, and that no country is immune to terrorism, while accepting that the Ukraine war has damaged international counter-terrorism cooperation.

Valle, of the Khorasan Diary, said that "some days ago, Turkish government sources revealed that Turkey helped Russia to disrupt a cell which intended to carry out another attack in Moscow ...

"So it means that there is an ongoing issue within the security environment in Russia which has been deepened by the war in Ukraine."

(Reporting by Andrew Osborn; Additional reporting by Mark Trevelyan; Editing by Mike Collett-White and Kevin Liffey)

By Andrew Osborn