Three years ago, the Islamic State (Isis) did not exist; now it controls vast swaths of Syria and Iraq. Showing off its handiwork daily via Twitter and YouTube, Isis has repeatedly demonstrated that it is much more than a transnational terrorist organisation – rather, it is an entity with sophisticated command, control, propaganda and logistical capabilities, and one that has proven its ability to take and hold strategically critical territory at the heart of the Middle East.

But as world leaders grapple with how to respond to this unprecedented crisis, they must first understand how Isis came to exist.

Principally, Isis is the product of a genocide that continued unabated as the world stood back and watched. It is the illegitimate child born of pure hate and pure fear – the result of 200,000 murdered Syrians and of millions more displaced and divorced from their hopes and dreams. Isis's rise is also a reminder of how Bashar al-Assad's Machiavellian embrace of al-Qaida would come back to haunt him.

Facing Assad's army and intelligence services, Lebanon's Hezbollah, Iraq's Shia Islamist militias and their grand patron, Iran's Revolutionary Guards, Syria's initially peaceful protesters quickly became disenchanted, disillusioned and disenfranchised – and then radicalised and violently militant.

The Shia Islamist axis used chemical weapons, artillery and barrel bombs to preserve its crescent of influence. Syria's Sunni Arab revolutionaries in turn sought international assistance, and when the world refused, they embraced a pact with the devil, al-Qaida.

With its fiercely loyal army of transnational jihadis, al-Qaida once again gained a foothold in the heart of the Middle East. Fuelled by the hate and fear engendered by images of dismembered children or women suffering from the effects of chemical weapons, disaffected youth from around the world rushed to Syria, fuelling an ever more violent race to the bottom.

Next door in Iraq, an emboldened Nouri al-Maliki waged his own sectarian campaign to consolidate power, betraying promises to his political partners to share it around. Within days of being welcomed at the White House and praised by Barack Obama for his leadership, Maliki returned to Baghdad to mastermind the arrest of his principal Sunni rival, vice-president Tariq al-Hashimi.

Supported by Iran and armed with US-made Humvees, M-16s, and M1A1 tanks, Maliki's forces closed in on Hashimi, only to see him flee to Kurdistan. Dozens of his guards were imprisoned on terrorism charges. At least one of them died under interrogation.

Another Christmas purge followed a year later, when a second prominent Sunni rival, the finance minister Rafea al-Essawi, found his home surrounded by Maliki's US-made tanks. He fled to the sanctuary of his tribe in Iraq's Anbar province, and was eliminated from Iraqi politics.

Facing mass unrest, Iraq's Sunni Arab provincial councils voted for semi-autonomous rule like that of the neighbouring Kurdistan region. Maliki blocked the implementation of a referendum through bureaucratic ploys, in contravention of Iraq's constitution.

Demonstrations of civil disobedience erupted across the Sunni provinces, as millions of Iraqis once again saw that they had no stake in Iraq's success – only its failure. Claiming intelligence that al-Qaida had penetrated the protest camps, Maliki crushed them with lethal force. Several dozen were killed during an Iraqi military raid in Hawija in April 2013, further inflaming what were already spiking sectarian tensions.

Despite pleas from the highest levels in Washington, Maliki's government did virtually nothing to halt the Iranian Revolutionary Guards' flights to resupply the Assad regime with thousands of tons of military hardware and ammunition. Meanwhile, a Shia Islamist ally of Maliki privately conceded to me last year that senior officials in the Iraqi government were turning a blind eye – or even actively supporting – the dispatch of thousands of Iraqi Shia fighters to participate in the spiralling Shia-Sunni holy war in Syria.

These militias – the Badr Corps, Asaib Ahl al-Haq, the Promised Day Brigades, among others – were warmly embraced by Maliki. Indeed, Badr's commander is none other than Iraq's incumbent transport minister, Hadi al-Ameri.

Ironically, al-Qaida's wholesale introduction into Iraq came at the hands of Assad's regime. From 2005 until the end of the American occupation of Iraq, Assad's military intelligence services and their Iranian backers sought to defeat the US forces by training, financing and arming al-Qaida operatives inside Syria and dispatching them across the border to foment chaos and destruction.

General David Petraeus and other senior American officials warned Assad that he was igniting a fire that would eventually burn his house down, but Damascus did nothing to stop the flow of fighters, culminating in a crippling blow to Maliki's government the day Iraq's foreign and finance ministries were bombed. Maliki publicly condemned his future ally in Damascus for the attack.

And so, Syria's unravelling spilled into Iraq, and vice versa. Powerful regional tribes such as the Shammar and Anezah, faced with countless dead and persecuted members in both countries, banded together with former Iraqi and Syrian military officers, embracing Isis jihadis as their frontline shock troops. Cash poured in from sympathetic donors around the region.

Iraq's four Sunni Arab provinces fell within days, entire Iraqi army divisions evaporated, and hundreds of millions of dollars worth of advanced American military equipment was seized by Isis and its allies. Fuelled by what was increasingly a regional Sunni-Shia proxy war, Iraq and Syria had become incubators for transnational jihad and religious hate.

As world leaders now consider a military campaign to confront Isis, they should remember the lessons of America's costly and largely fruitless engagements in Iraq, Afghanistan and Vietnam. They should understand that no amount of foreign military power can ever make up for the misrule of corrupt, failed governments like those in Damascus, Baghdad, Kabul or Saigon. Unless they want a regional holy war, leaders should especially discount the advice of some who are now calling for an alliance with Assad's genocidal regime – perhaps the single greatest root cause of Isis's rise.

Instead, they should embrace the lessons of Iraq's Sunni tribal awakening, that only Syrian and Iraqi Sunnis can defeat radical militant Sunni entities like Isis. Likewise, they should understand that only the mullahs in Tehran can help quell radical militant Shia entities like Lebanon's Hezbollah, Assad's intelligence operatives or Iraq's militias.

• Ali Khedery is chairman and chief executive of Dragoman Partners, a strategic consultancy. He served as special assistant to five American ambassadors in Iraq and as senior adviser to three heads of US Central Command from 2003-10. He was the longest continuously serving American official in Iraq.