Gen. David Petraeus, shown here while testifying before Congress in 2011 as the top U.S. general in Afghanistan, has a long history with Maj. Gen. Qassem Soleimani. (Photo by Mark Wilson/Getty Images)

Retired Army Gen. David Petraeus, closing in on a court date during which he is expected to plead guilty to mishandling classified information, was back in Iraq last week for the first time in three years, meeting with academics and leaders in the Kurdistan region.

Petraeus, in a post published today on The Washington Post’s World Views blog, weighed in on a variety of issues about the Islamic State militant group and security in the region.

It is Petraeus’s blunt reaction to an Iranian counterpart, Maj. Gen. Qassem Soleimani, that is particularly buzzworthy, however. Asked about widely distributed photographs of the Iranian military leader in Iraq recently, Petraeus said he has “several thoughts when I see the pictures of him, but most of those thoughts probably aren’t suitable for publication in a family newspaper like yours.”

[RELATED: Qassem Soleimani, Iran’s spy commander, introduced to a new generation]

“What I will say is that he is very capable and resourceful individual, a worthy adversary. He has played his hand well,” Petraeus said. “But this is a long game, so let’s see how events transpire.”

Petraeus added that Iranian influence across the Middle East is rarely helpful to the United States and its allies. The foremost threat to Iraq’s long term security, he said, isn’t the Islamic State, it’s Iranian-backed militias and the volatility they bring.

[RELATED: U.S. walks fine, awkward line when addressing Iranian airstrikes in Iraq]

Petraeus also relayed an old story. In 2008 — the same year that the U.S. Embassy in Baghdad’s Green Zone was shelled by Iranian-backed militias — Soleimani sent a message to Petraeus, the retired general said. It read: “General Petraeus, you should be aware that I, Qassem Soleimani, control Iran’s policy for Iraq, Syria, Lebanon, Gaza, and Afghanistan.”

He replied, through a messenger, by telling Soleimani to “pound sand,” Petraeus told The Post’s Liz Sly. A former executive officer of Petraeus’s, retired Col. Peter R. Mansoor, relayed a similar story in his 2013 book, “Surge: My Journey with General David Petraeus and the Remaking of the Iraq War.”

“In so many words, they were told to pound sand,” Mansoor wrote.

UPDATE: 1:10 p.m.: Wesley Morgan, a national security writer, adds the following on Petraeus’s exchange, based on the book “The Endgame,” by New York Times writer Michael Gordon: