Gen. David Petraeus, seen here in a file photo, was back in Iraq for the first time in three years. (Getty Images)

Gen. David H. Petraeus, who commanded U.S. troops during the 2007-2008 surge, was back in Iraq last week for the first time in more than three years. He was attending the annual Sulaimani Forum, a get-together of Iraqi leaders, thinkers and academics, at the American University of Iraq – Sulaimani in northern Iraq’s Kurdistan region.

[Read the full q&a: Petraeus: The Islamic State isn't our biggest problem in Iraq]

In his most expansive comments yet on the latest crisis in Iraq and Syria, he answered written questions from The Post’s Liz Sly, offering insights into the mistakes, the prosecution and the prospects of the war against the Islamic State, which he refers to by its Arabic acronym, Daesh.

Here are the five key takeaways from the interview.

1. Shiite militias and Iran now pose a bigger regional threat than the Islamic State

The Islamic State is already “on a path to defeat,” at least in Iraq, thanks to international, regional and Iraqi effort to rally against them. The biggest threat now is the Shiite militias taking over former Islamic State territories, with Iranian support.

“The foremost threat to Iraq’s long-term stability and the broader regional equilibrium is not the Islamic State, it is Shiite militias, many backed by — and some guided by — Iran.”

“The current Iranian regime is not our ally in the Middle East. It is ultimately part of the problem, not the solution. The more the Iranians are seen to be dominating the region, the more it is going to inflame Sunni radicalism and fuel the rise of groups like the Islamic State.”

2. You can't find a solution to the Islamic State without empowering capable local Sunni forces

It will not be enough to have Shiite units of the Iraqi army or militias conquer territory. Capable Sunni forces that will be regarded “as liberators, not conquerors” will have to be identified before battles are launched. And that will require broad political reconciliation between Iraq’s Shiite-dominated government and the country’s Sunnis.

“The bottom line is that Daesh’s defeat requires not just hammering them on the battlefield, but simultaneously, revived political reconciliation with Sunnis. Iraq’s Sunnis need to be brought back into the fold. They need to feel as though they have a stake in the success of Iraq, rather than a stake in its failure.”

As it is, reports of atrocities committed by Shiite militias against Sunnis in areas they conquer “constitute Daesh’s best hope for survival, pushing Sunnis to feel once again the need to reject the Iraqi forces in their areas.”

3. Syria is a "geopolitical Chernobyl" and needs to be addressed immediately

Though the Obama administration is embarking on a program to train and equip moderate Syrian rebels to fight the Islamic State, the effort falls short. If the new force is to function effectively, steps will also be required to halt airstrikes by the Syrian government of President Bashar al-Assad against areas under opposition control.

“Legitimate questions … can be raised about the sufficiency of the present scale, scope, speed and resourcing of this effort.”

It is also not enough to focus on Iraq and set aside the problem of Syria’s war to be solved later.

“I am profoundly worried about the continuing meltdown of Syria, which is a geopolitical Chernobyl. Until it is capped, it is going to continue to spew radioactive instability and extremist ideology over the entire region.”

4. America's influence is waning in the Middle East

The withdrawal of U.S. troops from Iraq, indications from the Obama administration that its priorities lay elsewhere and the lack of attention paid to Syria’s war have created the impression that American influence is waning.

“Our withdrawal from Iraq in late 2011 contributed to a perception that the U.S. was pulling back from the Middle East,” he says. “This perception has complicated our ability to shape developments in the region and thus to further our interests. These perceptions have also shaken many of our allies and, for a period at least, made it harder to persuade them to support our approaches.”

“Neither the Iranians nor Daesh are ten feet tall, but the perception in the region for the past few years has been that of the U.S. on the wane, and our adversaries on the rise. I hope that we can begin to reverse that now."

5. Petraeus told Iranian general Qasem Soleimani to “pound sand”

In 2008, as fierce battles raged in Baghdad between U.S. troops and Shiite militias – including those fighting against the Islamic State today – an Iraqi intermediary conveyed a message to Petraeus from Iran’s top general in Iraq, Qasem Soleimani, the head of the Quds Force of the powerful Iranian Revolutionary Guard Corps.

"General Petraeus, you should be aware that I, Qasem Soleimani, control Iran’s policy for Iraq, Syria, Lebanon, Gaza, and Afghanistan," the message said.

Petraeus says he responded by telling the interlocutor to tell Soleimani to "pound sand."

These days, Maj. Gen. Soleimani regularly visits the front lines in Iraq, much as Petraeus used to when he commanded troops in the country. Photos of his former adversary’s battlefield tours, widely posted on social media, provoke thoughts that Petraeus said he could not share.

“I have several thoughts when I see the pictures of him, but most of those thoughts probably aren't suitable for publication in a family newspaper.”