BEIRUT — Islamic State militants swept into villages in northwestern Syria as part of a surprise offensive against rival insurgents Friday, activists said. The militants threatened the country’s largest city, Aleppo, and dealt a blow to more moderate rebels under fire from Russian warplanes.

The Islamic State advance comes as Russia in recent days has backed a Syrian government offensive against rebel fighters elsewhere in the north and west. Russia says its military intervention in Syria is aimed at defeating the Islamic State, but most of Russia’s airstrikes have targeted Western-backed rebels instead of Islamic State infrastructure, U.S. officials say.

The Islamic State extremists, who have captured wide arcs of territory in Syria and Iraq, seized at least five villages and a rebel-held infantry school in Aleppo province on Friday, according to Syrian activists and an online statement issued by the militant group. The gains were the most significant for the Islamic State in Syria in months, according to the Britain-based Syrian Observatory for Human Rights, a monitoring group.

The infantry school is about 10 miles northeast of Aleppo and only a mile from a government-run industrial zone in the suburbs. Despite a push toward regime-controlled areas by the Islamic State, its militants were not struck by Russian warplanes, activists said.

In a statement issued Friday, the Russian Defense Ministry claimed to have killed 100 insurgents, including two Islamic State field commanders, in a strike on an ammunitions depot near Aleppo. It was unclear whether the air raid was related to the militants’ advance on the city, which has been ravaged by fierce battles between government troops and rebels in the four-year war.

Aleppo province is the area where the United States has planned to increase its own airstrikes against the Islamic State, hoping to push the militants back to the east.

Also in Aleppo, Islamic State militants killed an Iranian brigadier general and adviser to the Syrian government, Hossein Hamedani, Iran’s official news agency said Friday. Russia and Iran are both staunch allies of Syrian President Bashar al-Assad, and Iran has long stationed military advisers in the country.

“Brig. Gen. Hamedani was martyred by Daesh terrorists during an advisory mission in the suburb of Aleppo” on Thursday afternoon, said a statement from Iran’s elite Revolutionary Guard Corps that was read on Iran’s IRNA news agency. Daesh is the Arabic acronym for the Islamic State.