When the "Islamic State of Iraq and Syria" (ISIS) established its short-lived, so-called "caliphate" in the Middle East in 2014 and attempted to expand its influence across the Muslim world, many observers feared that the terror group would find fertile ground in Pakistan.
However, even with the complex history and networks of extremist groups in the country, these fears never materialised because of several factors.
This is not to say that the group did not make a serious attempt.
Over a span of several years, ISIS-linked or -inspired militants carried out a series of grisly attacks in Pakistan that targeted minority groups, security forces and others.
These atrocities included the massacre of more than 40 Shia Muslims in Safoora Goth in May 2015 and a brutal attack in October 2016 on a police training facility in Quetta that killed more than 60 cadets.
ISIS claimed responsibility for a suicide bombing in February 2017 at a Sufi shrine in Sehwan, Sindh Province that killed at least 90 people.
Although such high-profile terrorist acts grabbed headlines and instilled a certain degree of fear in the Pakistani populace, they undermined ISIS's advance in the country by provoking a swift and forceful response from Pakistan's security forces.
Pakistani officials, like their counterparts across the Muslim world, were shocked by ISIS's harsh interpretation of Islam, particularly the brutal punishments and executions carried out by the group in areas under its control.
For Pakistan, these concerns were further heightened because, early on, much of ISIS's Khorasan branch (ISIS-K) leadership and adherents consisted of Tehreek-e-Taliban Pakistan (TTP) militants who pledged allegiance to ISIS leader Abu Bakr al-Baghdadi.
The TTP, a sworn enemy of the Pakistani state, had waged a bloody terror campaign across the country that killed thousands of civilians and security personnel.
The notion that segments of the TTP could merge with a highly charged and well-funded global terrorist group was an unacceptable risk for Pakistani authorities. After all, it had taken the country almost a decade of hard-fought battles and complex operations to contain the carnage unleashed by the TTP.
While Pakistani officials initially downplayed the threat posed by ISIS in public, media reports later indicated that the country's security apparatus swiftly mobilised to counter the emerging threat shortly after ISIS announced the establishment of its "Khorasan" province in 2015.
Pakistani security forces and agencies carried out raids across the country, which reportedly resulted in the capture or killing of dozens of suspected ISIS-linked militants.
By 2016, more than 300 ISIS-linked militants -- including foreigners -- had been arrested by security forces, according to officials.
Then, in 2017, the Pakistani military launched a major operation in the then-Khyber Agency to flush out militants and secure the border with Afghanistan.
Since then, Pakistani authorities have maintained steady pressure on ISIS-K and affiliated terror groups, significantly curtailing their presence and operations in the country.
These efforts, in conjunction with a series of successful operations by Afghan and coalition forces across the border, have undoubtedly crippled ISIS-K's ability to operate in the region.
That progress is borne out by recent developments that include the loss of ISIS-K strongholds in Nangarhar Province, Afghanistan, and the capture of the group's leader, Aslam Farooqi, by Afghan forces.
Civil society rejects ISIS
While ISIS's ideology may have won over fringe extremist elements in Pakistan, the group's harsh interpretation of Islam -- particularly its brutal form of punishments and executions -- aroused overwhelming revulsion in the country's diverse population.
ISIS-K's attacks on Sufi shrines and minority groups led to a universal backlash from Pakistani civil society, including religious leaders and social activists.
Aside from protests and religious edicts condemning ISIS, this rejection has translated into vigorous support for security operations targeting ISIS-K in Pakistan and Afghanistan.
In light of Pakistan's diverse cultural, religious and ethnic landscape, the near-universal opposition to ISIS's rigid ideology is not surprising. The country has a rich history and tradition of Sufism with millions of followers who frequent shrines and other pilgrimage sites every year.
Pakistan hosts a significant Shia population that has largely co-existed peacefully with the country's Sunni majority since independence. Smaller sects and groups such as the Ismailis, Bohras and Parsis are well established throughout the country and make up a significant part of its social fabric.
Given these realities on the ground and sustained security operations, it is very unlikely that ISIS-K or its parent group will establish deep roots in Pakistan.