Turkish President Recep Tayyip Erdogan personally signed off on the involvement of Turkish banks in a scheme to cheat U.S. and U.N. sanctions on Iran, the architect of the scheme testified in U.S. federal court on Thursday.

“The prime minister at that time, Recep Tayyip Erdogan ... had given instructions, had given an order, for [Ziraat and Vakif banks] to start doing the trade,” Reza Zarrab testified.

The allegation is explosive given that Turkey is traditionally a U.S. ally, a member of NATO, and home to a major U.S. air base that has been key to the war against the so-called Islamic State.

Zarrab, a Turkish-Iranian gold trader, is the star witness in a trial relating to a scheme that used his companies to help Turkey covertly buy Iranian oil and gas, in violation of U.S. and United Nations sanctions.

Prosecutors say Zarrab and his co-defendant, Mehmet Hakan Atilla, used a number of Turkish banks and Zarrab’s companies to trade cash for gold, and allow Iran to pay its international debts with proceeds from its oil sales.

Since Zarrab's arrest in 2016, Erdogan has tried to get him released from U.S. custody through a series of diplomatic negotiations.

Zarrab fought the charges against him for over a year before beginning to cooperate with U.S. prosecutors this fall. In his first day of testimony on Monday, Zarrab admitted to bribing the former Turkish economy minister, Zafer Caglayan, with more than €45 million ($53.5 million) to facilitate the sanctions-cheating through Turkish state-owned banks.

Turkish observers have been eager to see how the trial, which relates to a quashed Turkish corruption scandal from 2013, would also impact the president. In the bombshell revelation Thursday morning, Zarrab said that Erdogan and former deputy prime minister Ali Babacan personally approved the involvement of Turkish banks in the scheme.

The revelation stems from Zarrab's extensive conversations with Caglayan, the former economy minister. Zarrab said the whole scheme—including bribe payments to heads of Turkish banks—occurred with Caglayan's approval.

"At the end of the day we did not hide anything from Zafer Caglayan, we did everything within his knowledge," he testified.

Erdogan, meanwhile, appeared to address the allegations in the trial in his own meetings this week.

“We have trade and energy ties with Iran. We did not breach the sanctions [on Iran]. Whatever the verdict is, we did the right thing,” Erdogan told ruling Justice and Development Party deputies Thursday morning, Hurriyet Daily News reported. "We have never made commitments to the U.S. [on our energy ties with Iran]."

“The world is not only about the U.S. We also have trade and energy relations with Iran,” Erdogan said.