Iran has entered into a formal agreement with Iraq to help rebuild its depleted military in the face of continued aggression from the Islamic State group, the two governments said Wednesday. Iraqi Defense Minister Khaled al-Obaidi met with Iranian Defense Minister Hossein Dahqan in Tehran Tuesday to finalize details and sign the agreement.

“The two sides stressed the need for consultations to ensure security, because terrorism affects not only security in Iraq but security throughout the region,” a statement released on state television said, according to AFP. Details on the agreement were scant, but Iraq and Iran “agreed to continue cooperation in the defense arena with the creation of a national army to protect the territorial integrity and security of Iraq.”

Iran has been training and equipping Iraqi Shiite militias to combat the Islamic State since the summer, when the Sunni Muslim extremist group’s offensive into northern Iraq led to mass desertion in the Iraqi regular army. The Islamic State gained control of vast tracts of territory in Iraq and Syria and maintains control over the major Iraqi city of Mosul. A general in Iran’s Revolutionary Guard was killed recently by sniper fire in the Iraqi city of Samarra while training troops, according to Iranian state media.

Iran sent combat troops to Iraq earlier this year to aid in defense of Shiite holy sites, Reuters reports. The reinforcements were sent after a request by Iraq’s Shiite-dominated government.

The agreement was reached just days after Iraq and Turkey agreed to pursue a unified effort to combat the group formerly known as ISIS in northern Iraq. Turkey has trained Kurdish peshmerga fighters to fight against militants in the region and has pledged to provide weapons and “further assistance” to Iraq, Reuters reported last week. Several Islamic State military operations have occurred near the Turkish border, and countless civilians have fled to Turkey to escape the danger.