Pakistani Prime Minister Nawaz Sharif reviews an honor guard during an August welcoming ceremony in Astana, Kazakhstan. (Stanislav Filippov/AFP via Getty Images)

— One year after he was nearly bounced from office, Pakistani Prime Minister Nawaz Sharif has hung on amid signs that the country could be on the cusp of a surprising turnaround.

After years of terrorist attacks, military coups and political upheaval, Pakistan for now has settled into a period of relative calm. Over the past nine months, government statistics show, major terrorist attacks have declined 70 percent, and Pakistanis are flocking back to shopping malls, resorts and restaurants.

The relaxed and optimistic mood here is benefiting Sharif politically, despite the humiliation he faced a year ago when he had to cede a chunk of his power to the military. Still, the arrangement is allowing Sharif to do something that Pakistani leaders have struggled to accomplish for much of the past decade: implement a road map for what a peaceful, stable Pakistan could look like. And in the process, Sharif is winning over skeptics despite his low-key leadership style.

“People are feeling more secure. There are development projects, and the perspective of people is changing to say, ‘Okay, now we can see things are going well,’ ” said Zafar Mueen Nasir, dean of business studies at the Pakistan Institute of Development Economics. “Of course, there will always be some criticism and always a second opinion, but as far as I am concerned, this government is at least showing some progress.”

Last summer, after Sharif’s first year in office was marked by disputes with political rivals and the country’s powerful military, tens of thousands of protesters camped out near the prime minister’s residence, demanding his resignation. At the time, there was widespread speculation that military leaders were considering a coup to oust Sharif over his diplomatic outreach to Pakistan’s archrival, India.

But as Islamabad slipped into an unusually chilly fall, Sharif outlasted the protesters. To remain in office, he reportedly had to make significant concessions to military commanders, including giving them full authority to make major decisions related to government policy toward Afghanistan and India.

Now, despite his reduced power, Sharif has turned his attention toward trying to rebuild a chronically sluggish economy while delivering shiny new amenities for residents.

It is a strategy that has become easier to implement this year, as a military campaign in Pakistan’s tribal belt and in the country’s largest city, Karachi, has been credited with reducing terrorist attacks and other crimes.

In the first eight months of this year, 680 civilians were killed in terrorist attacks, compared with 1,194 in the same period last year and 2,246 for the period in 2013, according to the South Asia Terrorism Portal, which monitors violence in the region.

With a rapidly growing population of 180 million, Pakistan faces many obstacles.

Energy shortages can keep the lights out for hours at a time, even in wealthy neighborhoods. Tens of millions of children suffer from poor nutrition, unsafe drinking water and sporadic access to medical care. The average Pakistani makes just $1,513 per year; many cannot find jobs. And Pakistan still has unsettled relations with India and Afghanistan, both of which accuse it of using favored terrorist groups as proxies to destabilize their societies.

Pakistan’s bare-knuckle political system also remains unsettled. Sharif, who still has 2 1/2  years remaining in his term, will continue to face relentless challenges from political foes eager to exploit the next crisis.

But in recent months, speculation about a civil war or an economic collapse has died down. Instead, credit agencies are boosting Pakistan’s bond ratings and large investment firms are advising clients to take a second look at opportunities here.

“It is the best, undiscovered investment opportunity in emerging or frontier markets,” Charlie Robertson, London-based chief economist at Renaissance Capital, told Bloomberg News in late June.

The International Monetary Fund, which has extended a $6.2 billion loan, released a report last month praising Pakistan for its 4.1 percent growth in gross domestic product this year, with a bump up to 4.5 percent projected for next year.

Many economists and analysts, however, remain skeptical that Pakistan’s economy and government have truly turned a corner toward happier, more prosperous times. They note that past moments of stability were quickly disrupted by tragedy, scandal or investor-rattling political or military crises.

“I still don’t really see many reasons for real optimism,” said Frederic Grare, director of the South Asia Program at the Carnegie Endowment for International Peace. “The economic situation is better right now, but the economic situation is better for almost everybody because energy is cheap.”

Sharif, however, has started delivering on his promise to make life a bit easier for Pakistan’s middle class, which for decades has endured substandard transportation, housing and employment options.

A millionaire business tycoon who also served two terms as prime minister in the 1990s, Sharif is promising to build 800 miles of highways and 14 power plants by 2018.

Several of the projects are designed to accommodate a major expansion of Chinese investment in Pakistan. China is hoping to use Pakistani roads and ports to open up new trading routes via the Arabian Sea, which could also help Pakistan expand its manufacturing base.

Although that partnership might take decades to reach its potential, Sharif is also implementing shorter-term goals to improve life for Pakistanis.

In May, he inaugurated a 14-mile rapid-bus system connecting the relatively affluent capital of Islamabad to the working-class city of Rawalpindi. A month earlier, the government introduced new cross-country, deluxe train service featuring air-conditioning, WiFi and televisions.

The Islamabad airport, consistently ranked as one of the most outdated in the world, has been upgraded with spiffier ticket counters, air-conditioned shuttle buses and its first fast-food restaurant.

“This government is far better, compared to previous governments,” Dilawar Ali, a 43-year-old engineer, said as he shopped at a market in Islamabad. “Look at these Metro bus projects, these roads and bridges. We could only imagine such things when we were in school and college kids.”

But Salman Zaidi, deputy director of the nonpartisan Jinnah Institute, said a closer examination of Sharif’s record still leaves major questions about his leadership style.

The prime minister, who declined to be interviewed for this article, lacks the forceful persona needed to become a unifying leader in a country with eight major political parties, Zaidi said. Sharif’s overall approach to governing, he said, is also outdated.

“He has a mind-set that comes from the 1950s, where large infrastructure projects equal development, and I think we have moved several decades beyond that,” Zaidi said. “A better estimation of a politician’s ability is ability to deliver on the ground in terms of education, in terms of justice, in terms of health care.”

Marvin G. Weinbaum, a Pakistan expert at the Middle East Institute in Washington, said there is also broad disappointment that Sharif has not done more to curb the electricity shortage or to overhaul the government’s bureaucracy.

“Yes, Pakistan has stabilized, but it’s stabilized because the military said to Nawaz, ‘Okay, if you want to stay in power, you are going to play by our rules,’ ” Weinbaum said. Sharif, he added, “is not seen as a real reformer.”

In Karachi, which generates a quarter of Pakistan’s GDP, business leaders are also angered by Sharif’s efforts to broaden Pakistan’s tax base — a key demand of the IMF and other creditors. Pakistani farmers are nervous about sluggish exports.

Still, for the broader Pakistani public, the country finally appears to be waking up after a decade-long slumber.

After the Ramadan religious observances ended in mid-July, surprising numbers of Pakistanis flocked to Himalayan mountain resort towns, overwhelming highways and hotels.

Last month, the largest crowd in years filled Islamabad’s streets to celebrate Pakistan’s Independence Day.

In Peshawar, where the Pakistani Taliban killed about 150 teachers and students at a school in December, merchants are also reporting an increase in business as violence has waned.

“No doubt, business activities are encouraging,” said Haji Khanan, 50, a shop owner in Karkhano Market, on the edge of Peshawar near Pakistan’s once-unruly tribal belt. “You can see for yourself. Look, there are no free spaces available” for parking.

Whether Pakistan’s momentum can be sustained, however, is a question most Pakistanis would be hesitant to try to answer.

“It’s 10 p.m., and I am here shopping with my kids and wife, and in previous years I would not be going out at this late hour,” Arif Khaliq, 43, said while buying back-to-school shoes. “Now, will this last? That is to be seen. . . . We can only pray.”