Relations between Iraq and Turkey are fast deteriorating. Iraq's Prime Minister Nouri Al Maliki has designated Turkey as a hostile state, banning Turkish companies from operating in the south and even called for the Iraqi army to be deployed against Turkish forces conducting cross-border attacks on Kurdish rebel PKK targets in the north.
The ebb in relations comes as Turkey pursues an increasingly aggressive Middle East foreign policy. The conflict in Syria puts Turkey, a major supporter of Syria's opposition forces, on the opposing end of a proxy war against Iran and Iraq.
Baghdad fears a Sunni Islamist takeover in Syria would embolden anti-government insurgents in Iraq's northern Sunni Arab provinces, which have supported the Syrian uprising and continue to provide a level of support for terrorist groups trying to undermine the government in Baghdad and Iraq's general stability.
Furthermore, Ankara provides a safe haven for high-ranking officials of the former Baathist regime, who in some cases organise and support militants operating out of Iraq's northern provinces. Turkey also refuses to extradite Iraq's fugitive vice president, Tarek Al Hashemi, who was recently found guilty of running death squads and sentenced to death in absentia by the Iraqi courts.
Ankara's long-term strategy is rooted in a broader objective: limit Iranian expansionism. It has undermined the Shiite-led, pro-Iran government in Baghdad ever since the government was formed in post-invasion Iraq in 2005. A further symptom of Ankara's strategy is its support of Mr Al Maliki's enemies domestically and abroad, including its aggressive economic partnership with the Kurdish Regional Government in Iraq, valued at $12 billion (Dh44 billion) in 2011, and its support for opponents of Bashar Al Assad's regime, Tehran's all-important geostrategic ally.
But Turkey should be careful that its wishes might come true. Geostrategic interests demand that it counterbalances Iranian prominence. However, despite revamping its foreign policy in response to the Arab uprisings, Turkey can no longer risk an unstable Iraq. Ankara needs to be careful, firstly, about increased autonomy, and possibly even independence, of the oil-rich Kurdistan region in northern Iraq and, secondly, developments that prompt its own restive population of some 20 million Kurds to demand similar rights.
It is against this backdrop that Prime Minister Recep Tayip Erdogan's visit to Iran last month should be examined. The tide is shifting against Ankara's position. Mr Erdogan's government is looking for fresh options, as the Assad regime continues to defy international pressure with the help of its friends in Iran, Iraq and Lebanon.
As well as giving increased leverage to Iraq's Kurds - now key players in the region and backed by their oil wealth - the Syria conflict has also allowed an autonomous Kurdish region to emerge in Syria's north-east. Much to the dismay of Mr Erdogan's government, this has emboldened the PKK, the rebel group Turkey has failed to defeat over the past 40 years and which has recently intensified its attacks on Turkish military targets.
The group, which fights for a mixture of political, territorial and human rights reasons for Turkey's marginalised and repressed Kurds, has seen its sister organisation in Syria, the PYD, take unparalleled control over Syrian Kurdistan. The PYD is increasingly playing the role of a local government as it sets up schools and military outposts in response to the continuing conflict and the possibility of a post-Assad Syria.
Turkey's response has come in the form of a military deployment along its borders with Syria, seen by many as a measure aimed in part at the PYD and Syria's Kurdistan region, rather than just reacting to the Syrian shelling of a Turkish border town last month.
That only shows how limited Ankara's options have become. Active military deployment in Syrian Kurdistan would force Turkey into a quagmire of a long-lasting conflict that it would neither be able to manage nor garner support for, domestically or internationally.
Turkey's response to the rise of the PKK and Syria's Kurds is telling because of its lack of foresight when it first sought the downfall of the Assad regime more than a year ago, as well as its failure to accommodate the gaps in its Syria and Iraq policies.
By alienating its regional neighbours, Turkey has seen them, in turn, revitalise their relationship and support for the PKK. Turkey may, therefore, find itself retreating in the coming months, as both patience with Mr Erdogan and support for his costly backing of the Syrian opposition runs out.
Ranj Alaaldin is a senior analyst with the Next Century Foundation, a conflict-resolution NGO based in London
On Twitter: @ranjalaaldin