Iran will attack Islamic State group jihadists inside Iraq if they advance near the border, ground forces commander General Ahmad Reza Pourdestana said in comments published on Saturday.

If the terrorist group (IS) comes near our borders, we will attack deep into Iraqi territory and we will not allow it to approach our border," the official IRNA news agency quoted Pourdestana as saying.

The Sunni extremists of IS control a large territory north of Baghdad, including in Diyala province, which borders Shiite Iran.

The United States launched air strikes on IS targets in Iraq in August and has since widened them to Syria, where the jihadist group has its headquarters, as part of an international coalition to crush the group.

Iran is a close ally of the Shiite-led government in Iraq and has been unusually accepting of US military action in Iraq against the jihadists.

It has provided support to both the Iraqi government and Iraqi Kurdish forces fighting the jihadists and has dispatched weapons and military advisers.