An incident last year involving a plane from Ghana , which landed in Istanbul with more than a ton of gold but had its cargo hidden from customs, illustrates the amount of money involved and the power of those who shared the profits.

A central bank regulation that allowed banks to keep their required reserve ratios in gold provided legal grounds for the plan. Turkish gold exports abruptly boomed. Money of unknown origin and illicit earnings were easily funneled into the banking system through gold accounts, since anyone was permitted to deposit gold without specifying its origin.

Shut out from the international banking system and thus unable to receive gas and oil payments in foreign currency, Iran was made an offer to be paid in gold through a gold account . With other Turkish banks reluctant to get involved, the task was given to the state-run Halkbank.

The formula was the joint work of Mahmoud Ahmadinejad, Rouhani’s predecessor who defied the West and coveted nuclear weapons, and Turkey’s Recep Tayyip Erdogan, then prime minister and now president.

ANKARA, Turkey — The formula Ankara and Tehran crafted to bypass international sanctions on Iran and keep their oil and gas deals going has become a potential source of tension between the two neighbors. A major factor in this is Iranian President Hassan Rouhani’s strategy to mend fences with the West to have the sanctions lifted and re-integrate Iran into the global economy and international community.

Under the scheme, Turkey’s gas and oil payments were deposited in a Halkbank account in gold, which was then transferred to Iran in various ways. Using middlemen, Iran sold the gold in countries with high jewelry demand such as India, Malaysia and Dubai, converting it to foreign currency.

Starting from 2008, the plan ran like clockwork. Iranian companies and middlemen in the guise of businessmen mushroomed in Turkey, keeping the trade rolling in return for commissions reportedly between 15% and 20%.

The total amount of those commissions could be estimated at up to $15 billion, given that the Turkish-Iranian trade volume in the 2008-13 period reached about $72 billion, including more than $40 billion in Turkish payments for oil and gas imports.

The tide, however, began to turn in February 2013 with a new round of sanctions that expanded the embargo to the sale of gold and precious metals and stones to Iran. Though Turkey said at the time the sanctions would not be binding upon it, the latest trade figures indicate that the United States’ warnings and its pressure on Turkish banks have borne fruit.

Turkey’s balance of payments for August, the latest to be revealed by the central bank, show that gold imports fell sharply to $357 million in the first eight months of 2014, down from $8.9 billion in the same period last year.

Until last year, Turkey imported $11-12 billion worth of gold per year and exported approximately the same amount. The striking decline reflects the halt in the gold trade with Iran and the resulting effect on commissions and bribes.

The architects of the scheme, Erdogan and Ahmadinejad, display some interesting similarities. They both rose to the top echelons of power from the mayoral offices of their respective countries’ biggest cities — Istanbul and Tehran.

In December last year, Erdogan grappled with corruption and bribery investigations that implicated his son Bilal, the sons of four Justice and Development Party (AKP) ministers and Iranian businessman Reza Zarrab, whom Erdogan described as a “philanthropist.” At roughly the same time, Ahmadinejad was embroiled in a corruption probe begun by Rouhani. The Iranian president, while making progress in the nuclear talks with the five permanent UN Security Council members, or P5+1 group, was chasing $14 billion missing from the gold trade with Turkey, separately from the billions of dollars paid as commissions.

Tehran contends the sum had been embezzled by Zarrab and demands the money from Turkey. During Erdogan’s visit to Tehran in January, the Turkish side was reportedly told that a bilateral preferential deal would not be signed unless the problem of the missing $14 billion was resolved. Erdogan allegedly called Justice Minister Bekir Bozdag and asked him to intervene to lift a judicial order freezing the assets and bank accounts of Zarrab, who was behind bars at the time. An Istanbul court hastily lifted the order, drawing an avalanche of criticism.

Under the AKP’s 12-year rule, some $36 billion in foreign money of unexplained origin has entered Turkey, according to central bank balance sheets. Speculation has it that those mysterious inflows include Iran’s missing $14 billion as well as bribes and commissions in the gold trade scheme.

In Iran, the $2.7-billion corruption investigation has led to the arrest of businessman Bab ak Zanja ni, a prime suspect in the probe and allegedly Zarrab’s business partner, amid speculation over links between Zanjani and Ahmadinejad.

If the alleged Zarrab-Zanjani partnership is uncovered, the Turkish government will find itself in trouble and the paths of the two “soulmates” will cross again, this time in the context of fraud accusations.

The use of public banks in transactions aimed at bypassing sanctions has prompted US warnings. In July, the Federal Reserve announced “enforcement action” against the New York branch of the state-run Ziraat Bank, Turkey’s largest lender, after it failed to meet obligations on measures against money laundering. The bank later sent letters to its clients asking them to terminate their accounts.

The outcome of Iran’s corruption investigation may lead to a political tremor in Turkey and add further strain on bilateral ties, already tense over Syria and Iraq.

In an October report, the OECD Working Group on Bribery raised concern over political interventions in the judiciary after a prosecutor newly assigned to the December 2013 corruption probe issued a verdict of nonprosecution against 96 people. “Risks that political interference may impact foreign bribery investigations and prosecutions remains a serious concern of the Working Group,” the report said.

Last week, the business compliance group Trace International published an index ranking countries according to bribery risk, based on assessment across four domains: business interactions with government, anti-bribery laws and enforcement, government and civil service transparency and the capacity for civil society oversight, including the role of the media. Turkey ranked 70th among 192 countries, with higher scores indicating greater risks.

It seems Turkey’s ill repute for bribery will continue with the AKP government. Ironically, at the G20 summit in Australia last week, the task to draw up an action plan to combat corruption and bribery went to the AKP government, as Turkey prepares to take over the group’s presidency on Dec. 1. Was it because of trust and confidence that the AKP stands out?