In November 2010, Turkey’s then prime minister, Recep Tayyip Erdoğan, was Muammar Gaddafi’s guest of honour in Libya and received the Gaddafi International Human Rights Award. Erdoğan piled praise on the Libyan dictator and called him “brother”.

Less than a year later, Gaddafi was dragged out of a drainage pipe where he had been hiding after fleeing the rebel siege of his hometown of Sirte. Jubilant Libyan insurgents hauled the despot, bloodied and dazed, onto the front of a pick-up truck like a hunting trophy and killed him.

Just four months after Gaddafi’s death, Erdoğan hosted Abdul Rahman al-Kaib, the prime minister of the National Transitional Council in Libya, congratulating his guest on the revolution. On the agenda were oil deals, the establishment of a joint bank, and a slew of opportunities for Turkish firms and contractors in Libya. The two prime ministers looked forward to what they hoped would be a bright future for Turkish-Libyan relations.

For many in the Turkish opposition, Erdoğan’s government was all too ready to get involved in the conflict in Libya that followed Gaddafi’s downfall, and there was outcry at the $300 million in cash that was flown to the NTC administration.

Their concerns, it transpired, were well founded. Turkey’s relations with Libya have been upended in the last six years, as the Libyan civil war has raged on. This was amply illustrated at last month’s Libya conference in Palermo, Italy, where rival administrations were encouraged to agree to terms for nationwide elections.

One of those rivals, Libyan National Army leader Khalifa Haftar, leads a Tobruk-based administration that dominates the east of Libya with broad international backing from Egypt, Saudi Arabia and Sudan as well as Italy, France and Russia. Relations with Turkey, however, are not so warm; the Turkish delegation was obliged to leave a meeting at the conference when Haftar’s party objected to its presence.

Turkish Vice President Fuat Oktay and the Turkish delegation stormed out of the conference early as a result. Oktay said no solution that excluded Turkey would be possible in Libya.

The missteps in Libya started early. Ankara had never thought it possible that Gaddafi would be overthrown; even after the uprising began, Erdoğan initially resisted NATO intervention.

But once the conflict was in full swing, it was Erdoğan’s government that provided the most significant support to the Islamist rebels.

As the war progressed, Turkey’s NATO allies in Italy, France and Germany, and the bloc made up of Saudi Arabia, Egypt and the United Arab Emirates threw their weight around to protect their interests in Libya. Yet Turkey was left out of the loop, and Turkish contractors’ building sites were looted, machinery was torched, and Turkish citizens were taken captive or deported.

As a supporter of the Tripoli-based Muslim Brotherhood administration that governs the west of Libya, Turkey stands almost completely alone. Haftar, meanwhile, commands the support of both Western countries and the Saudi-Egyptian bloc.

Just as in Iraq and Syria, where Turkey’s support of Islamist forces and parties has proven counterproductive, Erdoğan and his Justice and Development Party (AKP) government have had to pay a steep price for their so-called neo-Ottoman foreign policy in Libya.

Things may change in the future, but as it stands, this policy has had huge costs for Turkey’s economy in the Middle East, the Gulf region, and North Africa.

Libya had been the largest foreign market for Turkish contractors up to 2011, but that market has been lost. More than 600 Turkish firms, which had been involved in projects worth $28.8 billion in Libya, have for seven years been unable to claim their money, have seen their projects torched, and have lost machinery worth billions of lira, leaving them in dire straits.

Turkey likewise lost its share of the Iraqi market thanks to a foreign policy backing Sunni political groups in the country – in particular, Tariq al-Hashimi, the former vice president of Iraq who fled the country after being accused of directing jihadiist groups. Hashimi was sentenced to death in absentia in 2012, but Ankara continued to support the politician, offering him refuge in Turkey. As a result, Baghdad placed an embargo on Turkish goods, Turkish contractors were dropped from projects and tenders worth billions of dollars, and Turkey lost an export market that had once been its largest.

Meanwhile, the closure of border crossings after the beginning of the Syrian civil war in May 2011 meant the end of Turkey’s involvement in markets in Syria, which before the war had brought around $2 billion worth of business. It also removed one of the most important routes for the 120,000 Turkish trucks that once crossed Syria to export goods to Gulf countries and beyond. The economy of southern Turkey was hit hard as a result.

The trade lost with Syria in the last seven years amounts to $20 billion. Meanwhile, figures disclosed by Erdoğan at last weekend’s G20 summit in Argentina show that expenditure on Syrian refugees in Turkey has reached $33 billion. In other words, the lost revenues from exports, transport and border trade combined with the costs associated with the millions of Syrian refugees in Turkey, amount to losses of around $50 billion from Syria alone.

That price increases every day the Syrian war drags on, and it still does not count the money spent on Turkey’s military operations in northern Syria and the aid provided to its Syrian auxiliaries in the Free Syrian Army.

The ruling Justice and Development Party (AKP) welcomed three guests of honour at its congress in 2012: Khaled Meshaal, the leader of Palestinian Islamist militant group Hamas, Masoud Barzani, then leader of the Kurdish Regional Government of in northern Iraq, and Mohammed Morsi, the Muslim Brotherhood leader who was Egypt’s first elected president.

When Morsi was overthrown by the military in 2013, the general who took his place, Abdel Fattah al-Sisi, accused Turkey of meddling in Egypt’s internal affairs and supporting the Muslim Brotherhood and Hamas, which had both been declared terrorist organisations by his administration. Bilateral economic and political ties were cut, and both countries reciprocally withdrew their ambassadors.

Cairo went so far as to ban Turkish soap operas from Egyptian television channels, and even changed Ottoman street names. Dozens of Turks were apprehended on espionage charges, and it became more difficult to obtain business visas.

A deal signed by Morsi’s administration granting Turkish roll-on roll-off freight access to Egypt and on to Africa through the Egyptian port city of Alexandria was not renewed, and yet another channel for Turkey’s exports ground to a halt, leading to losses of $15 billion in six years.

So, the total losses inflicted on Turkey’s economy by the AKP’s foreign policy mistakes since the Arab spring uprisings have surpassed $100 billion in seven years.

These losses keep mounting by the day. Even in the case of Russia, relations with whom were set back on track in 2016 when Erdoğan apologised for downing a Russian jet the previous year, Turkey has not managed to return its trade volume and economic relations to its levels before the jet incident sparked a crisis in 2015.

While Turkey has extended visa-free travel to Russian citizens, Turks are still required to apply for visas going the other way, and many of the restrictions on Turkish exports, workers and companies are still in place.

The Russians have picked up a highly profitable deal from Turkey in the $22-billion Akkuyu project to build Turkey’s first nuclear power plant, as well as a $4-billion deal to supply Turkey with S-400 missile defence systems. The TurkStream pipeline project, meanwhile, will carry billions of cubic metres of natural gas under the Black Sea from Russia to Turkey, further deepening Ankara’s reliance on Moscow.

In the case of the Akkuyu project, the incentives promised by the Turkish government amount to a $10-billion contribution – around half the total cost of the project.

The favourable terms for the Russians in these deals have attracted criticism, but at the very least Ankara was able to strike a deal. As we observed yet again when the Turkish delegation stormed out of the conference on Libya, Turkey’s foreign policy mistakes all too often leave the country empty-handed, and we will likely continue to pay the price for years to come.