President Recep Tayyip Erdogan has said Turkish troops deployed in Iraq for training purposes in the fight against the Islamic State were not on combat mission and their pullout was “out of the question.”

The deployment of several hundred troops by Turkey in Bashiqa, close to an area held by IS in northern Iraq, has enraged Baghdad which has asked Ankara to withdraw all its forces.

“What they do in Bashiqa and at the camp is training,” Erdogan told a news conference in Ankara late on Thursday.

“The number of our soldiers will increase or reduce according to the number of peshmergas who are trained. (Their) withdrawal is out of the question.”

Baghdad has threatened to take the issue to the UN Security Council if troops are not withdrawn, saying they had entered the country illegally without its consent.

Turkey has a long-running training programme at a base near the city of Mosul, the Islamic State group’s main hub in Iraq, but the deployment last week expanded Ankara’s presence there.

The base gives Turkey a foothold in an area where a major ground operation against IS is eventually to take place, and where its archfoe, Kurdish rebel group the Kurdistan Workers’ Party, has also sought to expand its presence.

Erdogan’s comments came a day after he met with Iraqi Kurdish leader Massud Barzani, who has long-standing ties with the ruling Justice and Development Party (AKP) government.

Erdogan said Turkey, the United States and northern Iraq will hold a trilateral meeting on December 21 to discuss all issues. The venue for the meeting was not yet clear.

Prime Minister Ahmet Davutoglu spoke on the phone with US Vice-President Joe Biden on Thursday upon Washington’s request, sources from his office said.

The Turkish premier informed Biden of the training activity in Bashiqa since March and measures taken to protect the trainers and the camp there.

Davutoglu told Biden Turkey respected Iraq’s terroritorial integrity and was ready to contribute to its fight against the IS in coordination with Baghdad, according to the sources.

Turkish foreign ministry Under Secretary Feridun Sinirlioglu and intelligence chief Hakan Fidan also met with the Iraqi premier and foreign minister on Thursday, Davutoglu told Biden, the sources said.

Davutoglu has defended the deployment as an “act of solidarity” and said: “When the threats increased (to the lightly-armed Turkish trainers), we sent troops to protect the camp.”

Turkey this week urged its citizens to leave all areas of Iraq excluding Iraqi Kurdistan, due to increased security risks.