In the summer of 2014, Islamic State (IS) blindsided Iran by occupying a third of neighbouring Iraq. The self-styled caliphate captured a town only 20 miles from the border with Iran named Jalawla, where Islam’s second caliph Omar defeated the Persian Empire in 637. Jalawla was also where, 1,377 years later, the Iraqi dictator Saddam Hussein had invaded Iran. For Iranians, the enemy was once more at the gates.

Within days, Tehran dispatched Qasim Soleimani, the commander of its overseas paramilitary forces. There he co-ordinated the supply of 140 tons of military equipment per day to the Iraqi army and Shia paramilitary groups: small arms, mortars, Ababil surveillance drones and tank and artillery ammunition. The United States-led international coalition against IS would pick up the slack later in 2014. But right then Iran’s early intervention, led by Soleimani, was the only thing keeping Iraq together.

Iran also began deploying Soleimani on another front: launching a propaganda war centring on the self-styled “noble warrior,” a man who could appeal to both nationalists and religious conservatives. The “Commander of Hearts” became a fixture on domestic news. Iranian elites who would refer to him tongue-in-cheek as “Soleiman the Magnificent,” after the Ottoman sultan who so intimidated Europe, presented him as the nation’s protector against the barbarism of IS and the imperialism of the US. Tehran authorised the translation into Farsi of western articles that cast Soleimani as a formidable agent of Iranian regional power.

Instagram accounts dedicated to him sprung up, many with hundreds of thousands of followers. They showed Soleimani posing with children; Soleimani reading Gabriel García Márquez; Soleimani in a Palestinian keffiyeh; and Soleimani posing alongside Iran-backed paramilitary fighters in Iraq and Syria. Increasingly, he was also held up as a pious and humble servant of the Islamic Republic. When a state-run news agency asked his father why America feared him so much, he responded: “They’re afraid of Islam, not of my son.” Soleimani has enemies closer to home too—in October Iranian officials claimed they had foiled an assassination attempt against Soleimani, pinnng the blame on Israeli and Arab agents.

Tensions with Iran have been growing since Donald Trump’s decision last year to pull out of the nuclear deal. His subsequent campaign of “maximum pressure” has included the imposition of sanctions that have gutted Iran’s middle class and created poverty unseen for decades. Tehran has responded by using military force against US economic interests—the recent bombing of US giant ExxonMobil in Iraq and attacks on pipelines and refineries in Saudi Arabia appear designed to bounce Trump into a wider security deal that will perhaps lead to a fresh agreement between Iran and the US.

But if that strategy fails the Middle East could be enveloped by a war on an unspeakable scale. And Soleimani would be the man leading the Iranians into battle. Has the US fundamentally misconceived the motives of this commander and by extension Iran itself? And will that miscalculation lead to the US—and perhaps the UK—stumbling into a war with an enemy we don’t understand?

Soleimani commands the Qods force, an elite paramilitary army that reports directly to the Iranian Supreme Leader Ayatollah Ali Khamenei. He gathers intelligence, builds political alliances and creates a hostile environment for foreign forces opposed to Tehran. The methods have been consistent, even as the enemies changed. In Iraq, the enemy was first Saddam and later IS, and—indirectly—the US; in Syria, it has been the various rebel groups opposed to President Bashar al-Assad; in Lebanon, the Israelis who are ranged against his Hezbollah allies; and in Yemen, it is the official government that is being propped up by western-backed Saudi bombing.

Throughout Soleimani’s two decades at the top, he has had to navigate the forces unleashed by the US and British invasion of Iraq and Afghanistan, the associated rise of jihadist insurgents and, later, the democratic protests of the Arab Spring. Although his success has a lot to do with him capitalising on his enemies’ failures, he is a remarkable tactician. More than that, his life story is that of the generation of revolutionaries who control Iran today, and helps us to understand the choices Tehran makes, and does not make, in its Middle East interventions.

During the chaos of the 1960s White Revolution—the Shah’s botched land reform programme—Hassan Soleimani, a farmer in Iran’s tribal southeast, fell into debt. As he struggled to support his family, his 13-year-old son Qasim left the farm to get work in construction in nearby Kerman. The teenage Soleimani supported the exiled cleric—and the current regime’s founding father—Ayatollah Ruhollah Khomeini, and spent his free time at the zourkhaneh, a traditional Iranian gym that teaches martial arts, wrestling and self-discipline.

Like all great careers, Soleimani’s was blessed with serendipity. He is said to have been introduced to Ayatollah Ali Khamenei—the second and current supreme leader—who was then in hiding from the Shah. When the revolution came in 1979, Soleimani joined the Army of the Guardians of the Islamic Revolution, known in the west as the Revolutionary Guards and in Iran simply as the Guards. He was sent 2,000km north to help put down an attempted annexation by Kurdish Leftist groups. It was here that he made contact with an ambitious guard named Mahmoud Ahmadinejad, who would rise to the presidency in 2005.

In 1980, armed with western military equipment—including chemical weapons—Saddam Hussein launched a war against Iran that would kill one million Iranians and Iraqis. A 23-year old Soleimani was despatched to the trenches of Khuzestan province to take part in the war known to religious Iranians as the “Holy Defence” and to the secular as the “imposed war.”

Wartime stories about many of Iran’s major figures are shrouded in myth. One of the more entertaining tales about Soleimani explains how he earned his nickname “Toyota thief.” Finding himself behind enemy lines, he dressed up in the uniform of a dead Iraqi soldier and casually helped himself to dinner at the Iraqi mess before returning to his barracks with a new Japanese-made truck. Soleimani earned the respect of Guards commander Mohsen Rezaee, who promoted him in 1982 to lead the 41st Saarallah Division made up of recruits from Soleimani’s own Kerman province. He had a decisive role in Operation Fath-al-Mobin, a six-day counter offensive that cost tens of thousands of Iranian and Iraqi lives.

But in 1986, Soleimani disagreed with Rezaee over the war’s other major operation, Dawn 8, which he believed could not hold Iraq’s Al-Faw peninsula, a strip of marshland southeast of Basra. Before the deployment, he took his concerns to Ayatollah Akbar Hashemi Rafsanjani, who was helping to run the war, but the operation still went ahead. Soleimani was bleakly vindicated: 30,000 Iranians were killed in a Pyrrhic victory that led inexorably to Khomeini’s decision to call a ceasefire in 1988.

In the decade after the war, Soleimani’s disagreements with Rezaee stymied his ascent. He entered the political wilderness, tasked with the unenviable job of chasing Afghan drug cartels that were moving heroin into Europe to finance what would later become the Taliban’s takeover of Afghanistan. But in 1997 Rezaee was fired and Supreme Leader Khamenei promoted Soleimani to head the Qods brigade.

The Iran-Iraq war might have been a bloody stalemate, but Soleimani is mindful that this was the first war in a long time in which Iran had not lost territory. For hundreds of years the country has lacked stable borders. -Relations with Afghanistan have been fraught since the country was carved out of Iran in 1747. In the 19th century, Russia snapped up Iranian territory in Dagestan, Azerbaijan and parts of Armenia. The US and Britain invaded Iran during the Second World War and—more recently—the US has backed regional states and minority groups within Iran that challenge its territorial integrity. With this history, perhaps, any Iranian commander is likely to see enemies on many fronts.

After being promoted by Khamenei, Soleimani’s first assignment was to send arms, cash and intelligence to anti-Taliban forces. The Taliban had recently assumed control of Afghanistan, and in 1998 the group killed 10 Iranian diplomats and a journalist, almost provoking war. After 9/11, the anti-Taliban forces would become known as the Northern Alliance, which allied with Nato during its 2001 invasion. Soleimani encouraged the militias loyal to him to help the Americans oust the Taliban and al-Qaeda. But that co-operation came to an abrupt end in 2002, when President George W Bush labelled Iran, Iraq and North Korea an “axis of evil.”

A year later, the US-led invasion of Iraq caused a national security crisis for Iran. Soleimani was faced with three problems.

The first was the occupation. Iran feared that the US would establish a client state in Iraq that could serve as a base to challenge Iran along the 900-mile border. This wasn’t just paranoia. In Bush’s first term, the refrain among hawkish neocons was “Boys go to Baghdad, but real men go to Tehran.” But as America got bogged down, the threat ebbed away.

His second problem was Saddam’s ousted Baathists, many of whom had joined the Sunni insurgency against both the US and Iraq’s newly-ascendant Shia majority. Soleimani supported the Shias and especially the Supreme Council for the Islamic Revolution in Iraq (SCIRI), a coalition of Iraqi Shia political exiles, which Iran had nurtured and planned to establish as an incoming government if they had won the 1980-8 war. Soleimani drew on SCIRI’s military wing to assassinate Saddam-era officials—partly to forestall any attempt for Baathists to return to power and partly for simple vengeance.

Ironically, though, the biggest challenge for Soleimani was not the US, Sunni militants or former Baathists. It was a 29-year old Iraqi nationalist Shia cleric named Muqtada al-Sadr. Sadr’s influential family of Lebanese clerics had settled in Iran in the 1500s at the invitation of Iran’s first Shia dynasty, before later migrating to Iraq. The Sadrs were instrumental in the 1979 revolution and related to many members of Iran’s political elite. But Muqtada fiercely opposed Iranian influence in Iraq and commanded the support of millions of poor Iraqis, many of whom had fought against Iran during the war.

Sadr was raised in bloodshed. Saddam murdered his father and uncles during the 1990s, but he never fled. He took a dim view of Soleimani, SCIRI exiles and other outsiders. His allies hacked to death one returnee cleric from London, Abedel-Majid al Khoei, soon after the US invasion of 2003. Nonetheless, with his large loyal following Sadr was indispensable to undermining both the US occupation and its Iraqi proxies. To do that effectively, he needed arms and communications equipment. Soleimani could—and did—furnish him with supplies, and made himself useful by brokering ceasefires between Sadr’s Mahdi Army and other Shia groups aligned to Iran. In post-2003 Iraq, Iran was also a powerbroker that Sadr could simply not ignore. Soleimani kept a tab on the independent-minded cleric by embedding spies in his ranks. Over time, despite Sadr’s best efforts and strong domestic support, Soleimani’s SCIRI allies became the best-organised and best-funded political group in Iraq.

As Iranian influence on Iraq increased, the US was losing its grip—principally due to the Baathist/Sunni insurgency. Yet still it blamed Iran. In a message to the US ambassador to Iraq, Soleimani wrote: “I swear on the grave of Khomeini, I haven’t authorised a bullet against the US,” but acknowledged that his Qods brigade had targeted the British. He may have protested too much, but his capacity for restraint is real. Attacking the US was risky. And while he did funnel arms to so-called “special groups” that attacked US troops, he was happy to patronise other forces who worked with the Americans against the Sunni insurgents. Soleimani was less animated by his anti-Americanism than his determination to advance Iranian regional interests.

“[The US] is stuck in the mud in Iraq,” warned Rafsanjani in 2004, and added a warning: “that if Iran wanted to it could make their problems even worse.” In 2006, Soleimani personally brokered the selection of Iraq’s new government, handing the presidency to Iran’s pirnical allies in Kurdish Iraq, reassuring Sadr’s men they would get ministerial positions, and swinging everyone behind Nouri al-Maliki as prime minister—in return for the shared understanding that the Americans would soon be out. Maliki had a complex relationship with Iran. Tehran had provided him with a home and supported his resistance to Saddam during and after the Iran-Iraq war, but he had fallen out with his hosts and spent the end of his exile in Syria. Still, he was deeply entrenched with Iran’s security services and would provide a bulwark against American domination of the new Iraqi state.

During this same period, Soleimani was also focusing on Lebanon. Tehran was helping the Shia militant group Hezbollah to build a military capability to deter Israel both from invading Lebanon (after its withdrawal in 2000), and from acting on its threat to bomb Iranian nuclear facilities. The Qods force sent Hezbollah $100m (£81m) each year and worked to formalise its forces, modelling them on Iran’s Guards. Soleimani had a close relationship with Imad Mughniyah, Hezbollah’s international spy chief, and also reportedly established classes in Tehran’s embassy in Beirut to teach Hebrew to Hezbollah personnel.

In 2006 war came. Following tensions over prisoners of war in both countries—Soleimani is said to have been involved with an ambush of Israel Defense Forces soldiers—Israel invaded southern Lebanon and bombed the country for 34 days. But it faced fierce resistance from Hezbollah, and the stalemate was viewed by Arabs as a victory for the Shia group. Iran’s stock in the Arab world had not been higher since the 1979 revolution.

This would dramatically change with the Arab Spring. Tehran initially supported the protests believing that friendly Islamist governments would emerge. But when the protests reached Syria, Iran fell into a quandary. Syria had been the only Arab country to support Iran during its long war with Iraq. Conscious of this debt and mindful of their shared support for Hezbollah, Soleimani was convinced his country could not afford to jettison the Assad clan that had ruled Syria for 50 years.

Soleimani visited Damascus in 2011 along with Tehran’s chief Guard, Hossein Hamedani, who had successfully put down similar popular protests in Tehran two years earlier. They warned Assad that the police, and not the army, should be used to quell protests. Yet Assad used the army to prosecute several massacres of civilians throughout 2011, turning a protest into a full-blown insurrection.

Iran’s President Ahmadinejad calculated that Assad was not worth the candle. This left Iran’s Supreme National Security Council, which comprises representatives from both the government and the Supreme Leader’s office, split on whether to accept Assad’s panicked request for Iranian paramilitary support. Non-interventionists argued that defending Assad would be unpopular, doomed and expensive. Interventionists, including Soleimani, believed that if Syria fell to US-backed rebels, Iran would be next. “If we lose Syria, we cannot keep Tehran,” warned an influential Iranian cleric. The Iranian system of governance is often said to combine democratic and theocratic elements, but Soleimani has increasingly demonstrated the independent clout of a third arm of power: the military. It was he who, in 2012, broke the deadlock by persuading Iran’s Speaker of Parliament Ali Larijani to join the interventionists.

Soleimani flew to Syria and established the National Defence Forces (NDF), local paramilitary militias, whose leaders received training from Hezbollah in Lebanon and his own Qods force in Iran. In Soleimani’s view, the Syrian Army, which had suffered mass defections, was “useless.” The NDF’s immediate job was to fight the insurgency, but it was also a back-up military network in case Assad fell.

In 2014, Soleimani was dispatched by Tehran to Iraq to help Shia militias fight a new force: IS. Its rise, both in Iraq and Syria, initially turned the tide against Assad. Turkey, Saudi Arabia and Qatar, which until then backed different rebel groups in Syria, overcame their differences and threw their weight behind a separate coalition of rebels, the Army of Conquest. Rebels secured major victories in Idlib, eastern Homs and Daraa, while IS took Palmyra.

Iran needed another ally. In July 2015, Soleimani went to Moscow to meet the Russian defence minister and, -reportedly, President Vladimir Putin. The plan was for Iran to defeat rebel strongholds on the ground with the support of Russian air power. Two months later Russia started bombing, generating waves of refugees. Within three months of the intervention, Soleimani was pictured in Aleppo’s Old City, following its bloody recapture by the regime, a major turning point in the war. The past three years have been characterised by the slow but inevitable destruction of IS and myriad rebel groups that grew out of Syria’s failed revolution. Soleimani, a born revolutionary, was now deploying Iranian power to shore up a brutal and secular established order.

In an Iranian television documentary aired following Iran’s intervention in Syria, Soleimani is shown watching footage of himself as a commander in the Iran-Iraq war. The clip shows him before a squadron of troops weeping inconsolably, naming martyrs recently fallen in battle. “My heart aches,” says the young Soleimani. “Their bodies lay on the front, glowing even under soil.” Soleimani and other men in his generation that fought to overturn a US-client monarch, the old Shah, shared a definite ideology. They believed in the revolution’s restorative value not only for Iranian Muslims but also Muslims across the world dispossessed by western imperialism. Like Trotsky (but unlike later Soviets), they envisaged their revolution spreading across national borders.

US foreign policy gurus continue to view Iran through the lens of the 1980s. Mike Pompeo, the US secretary of state, refers to “Iran’s violent export of revolution”: he sees the Trump administration’s protection of Israel and opposition to Iran as a God-given mission that he will pursue until “the rapture.” But while the Americans still regard Iran as an agent of revolution, for Iran’s elites revolutionary talk has become mere rhetoric. You can see it in Soleimani’s career, which has just as often pursued counter-revolution in the Islamic world as the opposite—propping up the Iraqi and Syrian governments against revolutionary, often millenarian, currents in their societies. What he offers the country is not ideology, but rather the ruthless pursuit of Iranian interests as he sees them.

“The Islamic Republic of Iran has a specific strategy in the region,” said Soleimani’s adviser Sadollah Zarei in a recent speech. “We have definite principles, friends, and capabilities. And we have a coherent understanding of our enemy and we know where we should stand in the next 20 years.” And, despite the sanctions and isolation, Soleimani’s single-minded approach is working. Even the US admits that its strategy is blowing in the wind when it comes to countering Iranian influence in the region. “Soleimani’s accomplishments are, in large part, due to his country’s long-term approach toward foreign policy,” wrote Stanley McChrystal, the former commander of US forces in Afghanistan, earlier this year. “While the United States tends to be spasmodic in its responses to international affairs, Iran is stunningly consistent in its objectives and actions.”

The truth is that Iran’s original expansionist revolutionary ideology, which was seen from Tehran as a means to protect Muslims worldwide, but by America as a means to spread terrorism, died during the Iran-Iraq war along with half a million Iranians. Khomeini’s declaration that his acceptance of a ceasefire with Iraq in 1988 was akin to “drinking from the cup of poison” acknowledged the pain he felt in breaking with this ideology. After that war, Iran became just another nation seeking to preserve its territorial integrity and pursue its own economic and national security interests. Soleimani understands this better than anyone. While Iran’s elites have moved on, their US counterparts are stuck in the past.