BEIRUT, Lebanon — A coalition of Islamist insurgents, including a branch of Al Qaeda, seized most of the northern Syrian city of Idlib on Saturday after four days of heavy fighting. It was an unusually dramatic front-line shift in a four-year war that has long appeared to be at a stalemate even as it grows more bloody and complex.

If the insurgents cement their hold on Idlib — as they appeared to be doing in videos that showed them in control of government buildings in the city’s center — it would be only the second time during the war that the government has entirely lost control of a provincial capital, after the loss of Raqqa two years ago.

The northeastern city of Raqqa was seized by fighters that included members of the Nusra Front, Al Qaeda’s branch in Syria. It was a victory celebrated at the time even by more moderate opponents of President Bashar al-Assad but it later proved to be disastrous for the opposition.

The Islamic State, also known as ISIS, ISIL or Daesh, soon took over the city and used it as a base to expand its extremist rule. The group not only terrorized many Raqqa residents but dealt a strategic blow to the opposition, as global powers came to see it as a security threat and made stopping it a higher priority than ousting Mr. Assad.