US officials have released 11 Turkish military personnel - including special forces soldiers - ending a diplomatic row between the two countries.
The Turkish ministers had strong words with senior US officials by phone
The Turks were arrested on Saturday in the northern Iraqi town of Sulaymaniyah and taken to Baghdad by the US Army.
They are to spend the night in a guest house in the Iraqi capital and will be taken back to Sulaymaniyah by helicopter on Monday.
US officials have still not confirmed why they arrested the troops.
The Turkish Prime Minister, Recep Tayyip Erdogan, spoke to the US Vice President, Dick Cheney, for about a half hour and US Secretary of State, Colin Powell, called Foreign Minister Abdullah Gul in a bid to quell the row over the soldiers' detention earlier on Sunday.
Mr Erdogan called the situation "a totally ugly incident" and ordered the immediate closure of Harbur gate - the vital roadway that links Turkey to Iraq, when news first spread of the arrests.
Speaking after his conversation with Mr Powell, Abdullah Gul said he believed the "tasteless and ugly event" would be over on Sunday night at the latest.
"I hope Turkey's friendship and alliance [with the US] won't be damaged," he added.
Protestors have been showing their anger by ripping and burning US flags
In a written statement, the Turkish prime minister's office said Mr Erdogan asked Mr Cheney to immediately release the Turkish soldiers.
"It is expected that the special forces will be handed over to the Turkish side in Sulaymaniyah" after the talks, the statement added.
The detention has deepened the Turkish public's mistrust of the United States.
About 250 demonstrators gathered outside the US embassy in the Turkish capital, Ankara, on Sunday to protest against the detention of soldiers shouting "Free our soldiers," "America out" and "We will not be America's servants".
Supporters of the right wing Nationalist Action Party or MHP simultaneously staged anti-American protests in Istanbul.
Turkey has long had thousands of its soldiers in parts of northern Iraq to fight autonomy-seeking Kurdish rebels from Turkey who have set up bases there.
After the US-led invasion of Iraq, it also sent military advisers there to keep watch on Iraqi Kurds. Turkey fears that increasing Kurdish power in northern Iraq could encourage Kurdish rebels to revive fighting in Turkey's predominantly Kurdish southeast.
Turkey also enjoys close ties with ethnic Turkmen in the northern city of Kirkuk and is eager to prevent Iraqi Kurdish groups from gaining control of the oil-rich area.