BAGHDAD (Reuters) - Iraqi warplanes attacked an Islamic State explosives factory and other positions inside Syria on Thursday, Baghdad’s military said, in a rare air assault across the border.

Iraqi F-16 jets targeted the militants near the city of Hajin in coordination with the government of Syrian President Bashar al-Assad, an Iraqi military spokesman said.

Both governments have been fighting the hardline group, which declared a caliphate on both their territories in 2014 before it was forced back by an international offensive.

“Carrying out air strikes on Daesh gangs in Syrian territories is because of the dangers posed by said gangs to Iraqi territories and is proof of the improved capabilities of our armed forces,” the Iraqi military said in a statement.

Daesh in an Arabic acronym for Islamic State.

The U.S.-led coalition also fighting Islamic State said it gave the Iraqi mission intelligence support.

Earlier this month, Iraqi Prime Minister Haider al-Abadi said his country would “take all necessary measures if they threaten the security of Iraq,” referring to the jihadist militants who just three years ago overran a third of Iraq.

The prime minister declared final victory over the ultra hardline group in December but it still poses a threat from pockets along the border with Syria and has continued to carry out ambushes, assassinations and bombings across Iraq.

Iraq currently has good relations with Iran and Russia, Assad’s main backers in the seven-year-old Syrian civil war, while also enjoying strong support from the U.S.-led coalition.

Last year, Iraqi warplanes carried out at least one strike on Islamic State targets inside Syria, also in coordination with the U.S.-led coalition and with the approval of the Syrian government.