MOSCOW, Mar. 8 (Reuters) - The U.S. embassy in Russia warned that "extremists" had imminent plans for an attack in Moscow, hours after Russian security services said they had foiled a planned shooting at a synagogue by a cell from the Afghan arm of Islamic State.

The embassy, which has repeatedly urged all U.S. citizens to leave Russia immediately, gave no further details about the nature of the threat, but said people should avoid concerts and crowds and be aware of their surroundings.

"The Embassy is monitoring reports that extremists have imminent plans to target large gatherings in Moscow, to include concerts, and U.S. citizens should be advised to avoid large gatherings over the next 48 hours," the embassy said on its website.

It issued its warning several hours after Russia's Federal Security Service (FSB), the main successor to the Soviet-era KGB, said it had foiled an attack on a synagogue in Moscow by a cell of the militant Sunni Muslim group Islamic State.

It was unclear if the two statements were linked.

U.S. allies including Britain, Canada, South Korea and Latvia repeated the U.S. warning and told their citizens not to travel to Russia.

Most Western countries advise against all travel to Russia and say their citizens should leave. The U.S. has the highest level of warning for Russia - red "4 - Do not travel" - the same level as Afghanistan, Syria, Yemen and South Sudan and Iran.

The war in Ukraine has triggered the deepest crisis in Russia's relations with the West since the 1962 Cuban Missile Crisis.

The Kremlin, which accuses the U.S. of fighting against Russia by supporting Ukraine with money, weapons and intelligence, says relations with Washington have probably never been worse.

The FSB said an Islamic State cell was operating in Russia's Kaluga region as part of the Afghan arm of the group, which is known as ISIS-Khorasan and seeks a caliphate across Afghanistan, Pakistan, Turkmenistan, Tajikistan, Uzbekistan and Iran.

The group first appeared in eastern Afghanistan in late 2014 and established a reputation for extreme brutality.

The cell "was preparing to attack the congregants of a synagogue using firearms," the FSB said.

When tackled, the militants offered resistance by Russian special forces and were "neutralised" by return fire, it said.

"Firearms, ammunition, as well as components for the manufacture of an improvised explosive device were found and seized," the FSB said.

Diplomatic postings to Moscow are now considered among the most difficult in the world by Western countries.

The U.S. State Department ranks Moscow alongside Freetown, Mogadishu, Damascus and Kabul in hardship terms for its diplomats. Almost no U.S. journalits remain in Moscow.

Western diplomats in Moscow say intrusive surveillance and harassment are frequent and a guide known as "Moscow Rules", opens new tab that was developed by Western spies in Soviet times to guard against complacency has been updated for modern Russia.

Russia has long complained that its own diplomats are routinely harassed in major Western capitals and that its citizens are discriminated against amid what Moscow says is the worst wave of Russophobia for about a century.

Photo from Reuters