His stern, mustachioed face stares out from posters pasted to the backs of transport trucks. He's the most discussed personality on political talk shows. A Twitter hashtag credits him with improving everything from national security to Pakistan's performance in cricket.
But as he makes way for a successor, Sharif also leaves behind an army that has significantly increased its share of power through sweeping counter-terrorism policies that critics say have further weakened the country's democratic institutions.
After militants killed more than 130 children at an army-run school in December 2014, the Pakistani army set up special courts to try terrorism suspects and pressured the government to lift a moratorium on the death penalty. Hundreds were executed, many for crimes unrelated to terrorism.
This year is on track to see the fewest terrorism-related deaths in Pakistan in a decade. But although the army's Zarb-e-Azb offensive — named for a sword used by the Prophet Muhammad — has flattened villages and eliminated militant sanctuaries in the northern tribal belt, violence continues to flare elsewhere, including in remote southwestern Baluchistan province, where two major bombings killed 110 people in the last five weeks.
"The way the tide has turned in the fight against the militancy seems to be a major achievement, even though there are still a lot of problems," said Shaun Gregory, a professor at Britain's Durham University and director of the Pakistan Security Research Unit.
So far this year in Pakistan, 1,720 people – including 596 civilians – have been killed in violence attributed to terrorism, according to the South Asia Terrorism Portal, which tracks the fatalities. In 2013, the year Sharif took over, the death toll was 5,379, including 3,001 civilians.
"His legacy is strong in this regard," Gregory said. "And because that is such a preoccupation of the Pakistani people, the stock of the army has risen pretty well too."
To many Pakistanis, Sharif has brought swagger back to an army that was deeply embarrassed in 2011, when the U.S. raid on Osama bin Laden's hideout near Islamabad exposed the Pakistani military's incompetence, complicity with terrorism or both.
Prime Minister Nawaz Sharif, who is no relation to the general, had taken over the civilian government following a peaceful democratic transition and sought to try the former army chief and president,
Months after taking over the army, Gen. Sharif launched Zarb-e-Azb in mid-2014, deftly using social media to publicize the progress of the operation. The army listed results of clashes and a body count of some 3,500 suspected terrorists, although neither could be verified because journalists are all but barred from the tribal region.
The army also restored a measure of order to the southern port city of Karachi, which had become a lawless land of criminal gangs and militant networks. Security in the major cities improved to the point that China, Pakistan's biggest ally, began to push forward with a $46-billion investment package that represents the most important economic initiative in the country's history.
In recent months, the general's standing has grown as tensions escalate with neighbor and rival India over the disputed territory of Kashmir. Pakistan dismissed Indian claims that it supported a deadly militant raid on an Indian army camp in September, which prompted India to launch the first of a series of limited military strikes inside Pakistani territory.
Last month, Cyril Almeida, a respected columnist with the daily Dawn newspaper, reported that government officials had told army brass in a meeting that Pakistan risked international isolation over its failure to rein in militant groups such as those that allegedly attacked inside India.
That is a longstanding critique of the Pakistani military, but the story caused a furor and landed Almeida on a no-fly list that barred him from leaving the country. The newspaper stood by the story, but government officials disavowed it, adding to a growing fear among journalists and commentators that they cannot publicly criticize the military.
The Pakistani army is the most powerful institution in the country, having staged three coups since 1947. Sharif did not openly interfere in the civilian government and resisted calls to extend his term. Posters calling for him to take over the government surfaced in some Pakistani cities in July, but Sharif has not signaled any intention to enter politics or return to the military after his retirement.
When he began making "farewell visits" last week to various army garrisons, #ThankYouRaheelSharif became a trending topic on Twitter.
"His legacy is pursuing a resolute, more effective, transparent and military-centric counter-terrorism policy," said Ishtiaq Ahmad, an expert on politics and international relations in Islamabad.
"He had ample opportunities to repeat the past and topple the democratic transition in the country, but he chose otherwise…. At the same time the army as an institution is in a much stronger position under his command."
His successor, Lt. Gen. Qamar Bajwa, appointed by the prime minister, is a career infantry officer with a low profile and no social media presence. While analysts said they expected few significant policy shifts, Bajwa will have to navigate worsening relations with neighboring Afghanistan, which accuses the Pakistani army of allowing militants to flee over the border during the military offensive, and with the United States.
Despite the counter-terrorism operation, some U.S. lawmakers view Pakistan's actions against militants to be too little, too late. Congress withheld $300 million in military funding for Pakistan this year over its failure to do more to rein in extremist groups, particularly those attacking U.S. and Afghan forces in Afghanistan.
Many in Pakistan fear that President-elect
Ahmad, the analyst, said Bajwa would have to display more transparency and aggressiveness against terrorism to repair ties with a Trump-led United States.
"America under Donald Trump means business," Ahmad said. "Diplomatic niceties may not work under his presidency. "
Special correspondent Sahi reported from Islamabad and staff writer Bengali from Mumbai, India.
Follow @SBengali on Twitter for more news from South Asia