The US embassy in Russia issued a warning of an "imminent" attack by extremists in Moscow and notified American citizens to avoid large crowds just hours as Russian security officials said they thwarted a plot by Islamic State terrorists to shoot up a synagogue.

"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," it said on its website. 

The embassy, which has urged American citizens to leave Russia because of the war in Ukraine, advised them to "avoid crowds, monitor local media for updates and be aware of your surroundings."

The alert was issued after Russia's FSB said it stopped an attack on a Moscow synagogue by militants belonging to a cell of terrorists belonging to a Afghan-linked group known as ISIS-Khorasan that seeks to develop a caliphate in Afghanistan, Pakistan, Turkmenistan, Tajikistan, Uzbekistan and Iran, Reuters reported.

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

It said the militants put up some resistance but were eventually "neutralized."

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