WASHINGTON ― Michael Flynn, President Donald Trump’s former national security adviser, vetoed a plan to attack the so-called Islamic State’s capital of Raqqa in Syria in January ― a position that aligned with the desires of Turkey, which had paid him $530,000 to represent its interests, McClatchy reported Wednesday night.

But Flynn, a retired general, hadn’t always backed the views of Turkish President Recep Tayyip Erdogan’s regime, as HuffPost first reported last year. Quite the opposite: Last July, Flynn praised a coup attempt against Erdogan, criticizing the Turkish leader for being too close to President Barack Obama and calling the coup “worth clapping for.”

Flynn shifted to supporting Erdogan only after a Dutch company headed by a man with ties to Erdogan’s government hired his intelligence firm in early August. By November, Flynn had flip-flopped entirely. “We need to see the world from Turkey’s perspective,” he wrote in an opinion piece published on Election Day. “We must begin with understanding that Turkey is vital to U.S. interests. Turkey is really our strongest ally against the Islamic State in Iraq and Syria (ISIS), as well as a source of stability in the region.”

Wednesday’s McClatchy report adds a dimension to this flip-flop. Flynn had demagogued for years about the supposed dangers of Muslims and Islam. “Fear of Muslims is RATIONAL,” he tweeted in February. “Islam is not a real religion, but a political ideology masked behind a religion,” he claimed.

ISIS received special attention in Flynn’s harangues. He told The New Yorker in February that Obama had “too narrowly defined” efforts to defeat the group and called for “fighting these guys on the battlefield.”

But when the Obama administration asked the Trump administration in mid-January to approve a plan ― fiercely opposed by Turkey ― to arm Syrian Kurds to retake Raqqa from ISIS, Flynn, who was being paid by Turkey, balked.

“Don’t approve it,” Flynn said, according to a February report in The Washington Post cited by McClatchy. (Turkey opposes arming the Syrian Kurdish militia, known as the YPG, because it believes the YPG has ties to the PKK, an organization of Kurdish fighters in Turkey that both Turkey and the U.S. have listed as a terrorist group.)

The Trump administration knew at the time ― and, indeed, before Trump appointed Flynn ― that the FBI was investigating him for secretly serving as a paid agent of Turkey while campaigning for Trump, The New York Times reported Wednesday night.

But Trump listened to the paid Turkish agent who was also serving as his national security adviser anyway, and the operation against the ISIS capital was delayed for months. The president continued to allow Flynn to sit in on national security briefings, as he had throughout the last months of the campaign and through the transition ― all times during which he was being paid by Turkey.

Attempts to contact Flynn for comment were unsuccessful, but associates of his told the Times he believes the investigation into him is part of a political effort by the Obama administration to keep him out of the White House.

The Trump administration protected Flynn despite repeated warnings from people inside and outside the government that he was compromised. Acting Attorney General Sally Yates told the White House a week after the inauguration that Flynn “could essentially be blackmailed by the Russians” after misleading Vice President Mike Pence about meetings he had with the Russian ambassador, she testified to a Senate subcommittee earlier this month. It took Trump 18 more days to fire Flynn.

Trump fired Flynn on Feb. 13, several weeks after the Raqqa recommendation. He then pressured FBI Director James Comey the next day to close the investigation into Flynn, according to Comey’s notes, the Times reported Tuesday.

Comey did not.

Trump fired Comey on May 9. The same day, media reports emerged that the president had changed his mind about Syria: He had decided there was only one way to defeat the Islamic State without involving large numbers of U.S. troops. He would arm the Syrian Kurds after all.