By Gulsen Solaker
ANKARA (Reuters) - Turkey and Iraq, both worried by the advance of Islamic State, pledged on Thursday to work towards greater military cooperation in their fight against the ultra radical Sunni militants.
Turkey is already training Kurdish peshmerga fighters in northern Iraq to help them battle Islamic State insurgents, who control territory in Iraq and Syria.
Some major battles are being fought very close to Turkish borders, and Turkey has become a haven for thousands who fled the militants.
Turkey is ready to work with Iraq to extend its military assistance, Prime Minister Ahmet Davutoglu said at a joint news conference with his Iraqi counterpart, Haider al-Abadi.
Abadi, the first Iraqi prime minister to visit Turkey since his predecessor Nouri al-Maliki's visit in 2010, signalled Turkey could also be sending arms to Iraq.
"There are preparations being made with the assistance of the Turkish side in providing us with weapons," Abadi said.
Turkey, a NATO member with a 1,200 km border with Syria and Iraq, began its training of Iraqi peshmerga forces last month, and said this could be extended to Iraq's National Guard.
"Our defence ministers will carry out a more detailed study on this issue. We already have provided support in terms of military training. We are ready to give whatever further assistance we can in these areas," Davutoglu said.
Ankara has refused to take a frontline military role in the air offensive mounted by a U.S.-led coalition against the insurgents, saying there could be no lasting stability with air strikes alone.
Supported by air strikes, Iraqi Kurdish fighters this week broke an Islamic State siege of Sinjar mountain in western Iraq, freeing hundreds of Yazidis who had been trapped there for months.
Abadi said Iraqi forces were fighting to root out the militants and were regaining territory.
"Their grip is weakening," he said.
Turkey and Iraq have had tense relations for years. Maliki's government was angered by Ankara strengthening ties with northern Iraq's autonomous Kurdish region, with which Baghdad had been locked in a bitter feud over oil.
Relations have improved since Abadi took office in September and since Baghdad and Arbil clinched an initial deal on the sharing of oil export revenues.
Contrary to Maliki, Abadi said Iraq supported increasing its oil exports via a Kurdish-built pipeline going through Turkey. "We would like strengthen this agreement and carry on these exports via Turkey. This is in the interest of Iraq."
(Aditional reporting by Saif Hameed; Writing by Humeyra Pamuk; Editing by Raissa Kasolowsky)