BAGHDAD - Thousands of Iraqis protested on Saturday against Ankara’s deployment of troops to a base near the northern city of Mosul, with some burning Turkish flags and threatening violence against the soldiers for what they see as a violation of sovereignty.

News of the deployment of 150 Turkish soldiers earlier this month triggered a crisis between Ankara and Baghdad, which has appealed to the United Nations Security Council to demand their immediate and unconditional withdrawal. Ankara has refused, saying the troops were part of an international mission to train and equip Iraqi forces to fight Islamic State, which still controls a large part of the country. Baghdad denies inviting such a force.

At least 4,000 demonstrators gathered in Tahrir Square in central Baghdad on Saturday, and several thousand more in the oil city of Basra in the south, including Shi’ite militia members who held up banners reading “Death to Turkey. Death to Erdogan”.

“We consider any military presence on Iraqi land as foreign aggression which we should stand against using all possible means,” Hadi al-Amiri, a Shi’ite lawmaker who heads the powerful armed Badr Organisation, told protesters in Baghdad. The rallies were organised and led by Shi’ite militia groups, which have threatened to use force against Turkey unless it withdraws.

Pointing his pistol towards an image of Erdogan, Amjad Salim, a local commander in the Badr Organisation in Basra, said: “We are on high alert now awaiting orders from our commanders to set fire to the ground beneath the feet of Turkish soldiers.” In Baghdad, Reuters reporters saw angry protesters trample on the Turkish flag and hit a caricature of Erdogan with slippers in a mark of disrespect.

“If Turkey thinks Iraq is busy with fighting Daesh and it can seize the opportunity to deploy troops then it should think twice before making such a mistake,” said Abu Muntathar al-Moussawi, a local commander in Iranian-backed Asaib Ahl al-Haq paramilitary group. “We can target Turkish soldiers and coming days will prove it.”

But not all the demonstrators were fighters, including businessman Hussein al-Samawi, who came from the city of Samawa, south of Baghdad, to take part. “We agree with every step the prime minister is taking right now,” said Samawi, who was dressed in a suit. “We have to pursue the political track, but if it doesn’t work, force will be the only option,” he said.

The demonstration was mostly attended by young men in military uniforms and was well organised, with large processions converging on Tahrir Square in central Baghdad. The area was heavily guarded by security forces positioned on the ground and atop buildings, and roads were closed for up to several kilometres away from the protest site.

Moreover, At least six Iraqi border guards were killed on Saturday when a suicide bomber drove a truck packed with explosives into an outpost near the border with Saudi Arabia in an attack claimed by Islamic State.

In a statement posted online, Islamic State said the attack on an outpost in the desert area of Iraq to the west of Nukhaib targeted the army and “rejectionist” militias — a term used by the Sunni militants to describe Shi’ite Muslims. Interior Ministry spokesman Saad Maan said in a statement six guards had been killed, including their commander, and 10 others wounded.

Border police sources put the death toll among higher at eight. Iraqi government forces, backed by U.S.-led air strikes, have been trying to push back Islamic State militants since they swept through mainly Sunni Muslim provinces of western and northern Iraq last year.