BAGHDAD — Fighters from a Sunni extremist group attacked an army unit in a northern Iraqi city on Tuesday, killing 15 soldiers in a rampage of beheadings, shootings and a hanging, security officials said.

The strike on the army unit in Mosul by members of the Islamic State of Iraq and Syria, or ISIS, showed how the group has moved beyond Anbar Province, west of Baghdad, where it controls Falluja and parts of Ramadi, and extended its reach into territory throughout the country.

On Tuesday, the ISIS extremists drove up to the army unit, which was deployed to secure an oil pipeline that links Iraq and Turkey, in more than a dozen sport utility vehicles, bent on slaughter. They beheaded five soldiers, shot nine dead and hanged one on a wall, torturing him to death, the officials said.

The authorities said that it was becoming more common for large numbers of ISIS extremists to carry out deadly raids and bombings in areas outside Anbar Province as the army of the Shiite-dominated government tightens its cordon there for offensives against ISIS and other Sunni militias.