A senior Iranian military commander repeatedly warned Kurdish leaders in northern Iraq to withdraw from the oil-rich city of Kirkuk or face an onslaught by Iraqi forces and allied Iranian-backed militias, Kurdish officials briefed on the meetings said.
Major-General Qassem Suleimani, commander of foreign operations for Iran's elite Revolutionary Guard, travelled to Iraq's autonomous Kurdish region to meet Kurdish leaders at least three times this month before Baghdad's lightning campaign to recapture territory from the Kurds across the north.
The presence of Gen Suleimani on the front lines highlights Tehran's heavy sway over policy in Iraq.
The commander met leaders from the Patriotic Union of Kurdistan (Puk), one of the two main Kurdish political parties, in the Iraqi Kurdish city of Sulaymaniyah the day before Iraqi prime minister Haider Al Abadi ordered his forces to advance on Kirkuk, according to a Puk lawmaker briefed on the meeting.
His message was clear: withdraw or risk losing Tehran as a strategic ally.
"Abadi has all the regional powers and the West behind him and nothing will stop him from forcing you to return back to the mountains if he decides so," the Puk lawmaker quoted Gen Suleimani as telling the party leadership.
The Iranian general evoked late Iraqi president Saddam Hussein’s massive attack on a Kurdish rebellion in 1991, when almost the entire Kurdish population fled northern Iraq to the mountains, the Puk lawmaker said.
"Suleimani's visit … was to give a last-minute chance for the decision-makers not to commit a fatal mistake," said the lawmaker, who like others interviewed in this story declined to be identified because of the sensitivity of the issue.
Commanders of the Iraqi Kurdish forces, known as the Peshmerga, have accused Iran of orchestrating the Shiite-led Iraqi central government's push into areas under their control, a charge senior Iranian officials have denied.
But Iran has made no secret of its presence in Iraq.
"Tehran's military help is not a secret anymore. You can find General Suleimani's pictures in Iraq everywhere," said an official close to Iranian president Hassan Rouhani.
"Now, beside political issues, Kirkuk's oil is a very key element for Iran, which is an Opec member. Control of those oilfields by Iran's enemies would be disastrous for us. Why should we let them enter the oil market?."
Kirkuk fell to Iraqi government forces on Monday. Their offensive followed a referendum last month in which the Kurdish region voted to secede from Iraq against Baghdad's wishes.
Iraq's two main Kurdish parties have been at odds over both the referendum and the approach to the crisis in Kirkuk, which the Kurds consider to be the heart of their homeland.
The Puk, a close ally of Iran, accused its rival, the Kurdistan Democratic Party (KDP), of putting the Kurds at risk of military intervention and isolation by pushing hard for the vote, which won wide approval for independence.
Gen Suleimani has been allied to the Puk for years, but the referendum has drawn him even closer to Kurdish politics and expanded Iran's reach in Iraq beyond the central government in Baghdad.
The Iranian general is no stranger to conflicts in Iraq, which fought an eight-year war with Iran in the 1980s. He has often been seen in footage from the front lines, and Iran has long helped Baghdad to carry out its military strategy through paramilitary mainly Shiite forces which it funds and arms.
Before the September 25 referendum, Gen Suleimani suggested to Kurdish leaders that holding a vote on secession — which Iran feared would encourage its own Kurdish population to agitate for greater autonomy — would be risky.
"The Iranians were very clear. They have been very clear that there will be conflict, that these territories will be lost," said one prominent Iraqi Kurdish politician who met Gen Suleimani ahead of the referendum.
On October 6, barely a week after the vote, Gen Suleimani attended the funeral of Puk leader Jalal Talabani. Again, he wanted to make sure even his closest Kurdish allies understood the dangers of not withdrawing from Kirkuk, officials said.
A senior Iranian diplomat in Iraq and an official in Iran close to Supreme Leader Ayatollah Ali Khamenei's office said Gen Suleimani met with Kurdish leaders after Talabani's funeral and urged them to withdraw from Kirkuk; in exchange, the commander said Tehran would protect their interests.
Gen Suleimani met with one of Talabani's sons, Bafel, a few days after his father was buried, one of the Puk officials said.
"Suleimani said Abadi should be taken very seriously. You should understand this," the official said.
An Iranian source in Iraq meanwhile said Gen Suleimani was in Kirkuk two nights before the Iraqi government offensive for "a couple of hours to give military guidance". Iraqi intelligence sources said Tehran sent a clear signal to the Puk.
"We understand from our sources on the ground that neighbouring Iran played a decisive role in making the Puk chose the right course with Baghdad," one Iraqi intelligence official said.
Tensions over the referendum and Kirkuk have deepened divisions between the two main political parties in northern Iraq. The KDP accused the Puk of betraying the Kurdish cause by capitulating to Iran and striking a deal to withdraw — something the Puk has strongly denied.