Canadian soldiers opened fire on Islamic State group extremists in Iraq over the last week in what a general called an act of self-defense.

Brig.-Gen. Michael Rouleau, commander of special operations command, said Monday the soldiers were visiting front-line positions with Iraqi forces when they came under mortar and machine-gun fire.

The Canadians, whose job is to train and advise the Iraqi military in their battle against the Islamic State group, were at the front to help plan an Iraqi operation.

Rouleau says the Canadians used sniper fire and "neutralized" the enemy positions without taking any casualties.

He says that while Canadian soldiers are not participating in active combat, they have the right to fire back if fired upon.