Pakistan’s Prime Minister Nawaz Sharif in 2013. (Mian Khursheed/Reuters)

Afshin Molavi is co-director of the emerge85 Lab and a senior fellow at the Foreign Policy Institute of the Johns Hopkins University School of Advanced International Studies.

Shortly after Egypt’s 2011 uprising ended with the fall of President Hosni Mubarak, prominent Egyptian investor Ahmed Heikal said: “If we get things right, we could be Turkey in 10 years. If we get them wrong, we could be Pakistan in 18 months.”

Everyone understood the subtext: Turkey was the model; Pakistan was the train wreck. After all, at that time Turkey had come off a decade of high growth, doubled its gross domestic product over the previous decade, tripled its per capita income and was still seen as an emerging-market darling. It even lent its first initial to the latest and newest acronym by Goldman Sachs’ Jim O’Neill (he of BRICS fame) — Turkey was the “T” in MINT: Mexico, Indonesia, Nigeria and Turkey.

As for Pakistan, well, it was Pakistan, known mostly for terrorist attacks like the one perpetrated last week by an Islamic State suicide bomber that left at least 80 people dead and incited a furious government crackdown on militants. Headlines of terrorism, coups and instability, plus years of underdevelopment and poverty meant that no one was going to add Pakistan to a catchy acronym.

But not so fast. Look beyond the headlines and see Pakistan today. It boasted the best stock market in Asia in 2016. The high-flying Karachi Stock Exchange Index is up more than 52 percent over the past year — and rising.  The exchange broke through the vaunted 50,000 mark last month — a first in history. What’s more, Pakistan is winning plaudits from the International Monetary Fund, and its economy is forecast for a healthy 5.2 percent growth rate in 2017, according to the World Bank.

As Pakistan turns a corner, Trump administration policymakers fixated on the terrorism threat just might miss this extraordinary opportunity in a country that has long been a terror bane. Three key factors are driving Pakistan’s economic awakening: an improved security climate even despite the most recent attack, relative political stability and a growing middle class. These three interlocking pieces are fueling Pakistan’s growth story — a vital story given the size and geopolitical weight of the nuclear-armed South Asian nation of nearly 200 million people.

In mid-May, the world’s largest research-based provider of index funds, MSCI, will officially “graduate” Pakistan from its frontier-market category to the more prestigious — and well-capitalized — “emerging market” index. It will join 23 other countries on the index that represents 10 percent of world capitalization.

Turkey is also on that index, but its fortunes are diverging rapidly. It is no longer the emerging-market economy on the rise, as it slows under the weight of political uncertainty, a deteriorating security situation, questions over its relations with the European Union and an intensified Kurdish militant insurgency in the southeast.

Pakistani Prime Minister Nawaz Sharif and the generals may finally have gotten a reasonable handle on the deteriorating security climate — although attacks such as the suicide bombing at the Sufi shrine last week are likely to persist. And in 2013, when Sharif was elected, it marked the first democratic transition of power in the coup-prone country. Sharif entered office as the great global transformation taking place worldwide — of technological connectivity, rapid urbanization and rising middle class consumption —  continued to churn. And Pakistan has not missed that train.

Robust middle classes are vital to healthy societies and growing economies, and Pakistan’s middle class may have reached a tipping point, with some estimates suggesting that it accounts for more than half the population. Brookings Institution scholar Homi Kharas argues that Pakistan’s consumer middle-class market could hit $1 trillion by 2030. To be sure, the country still suffers from deep pockets of poverty, a backward education system and the jihadist threat, but as the middle class grows, demands will grow for more opportunities, better services and more security and stability.

These middle classes are also attracting foreign investment. Ishrat Husain, former governor of the State Bank of Pakistan, told me that middle classes are driving impressive 25 percent rates of return for large multinational consumer companies such as Nestle and Procter & Gamble, and that the middle-class growth is sparking increased production of cement, steel, automobiles and the like. He sees it as one of the key reasons for current bullishness on Pakistan.

That bullishness has led Pakistan to enter the emerging-markets acronym vernacular. One of the latest post-BRICS acronyms of rising economies making the rounds: VARP, for Vietnam, Argentina, Romania and Pakistan. Yes, that Pakistan.

But the biggest test of whether Pakistan’s government can deliver might be something more simple: Will the lights stay on? Pakistan has an electricity problem. The country has long had electricity shortages with widespread rolling blackouts plaguing both urban and rural areas. In fact, Sharif made expanding electricity access a major campaign promise.

Enter China. Pakistan’s giant neighbor has pledged a whopping $46 billion program to build the China-Pakistan Economic Corridor that will build new highways, overhaul railway and create new infrastructure to support 10,000 megawatts of additional power.

If Pakistan succeeds in taming its electricity gaps with China’s help, the virtuous circle of growth will continue, and a key South Asian, nuclear-armed power could be headed for a decade of normalcy. If this materializes, that would be a big relief to the international community in dire need of countries of Pakistan’s size to begin delivering more for their people.