Gen Ashfaq Kayani, the head of the Pakistani army who is expected to step down later this year, is among the most well-known senior military figures of our times. While his strengths and weaknesses have been endlessly chronicled and assessed by a huge variety of analysts, my advantage is that I have known him for many decades.
Since he numbered among Gen Musharraf's selections for promotion, he was considered a loyalist even though he wasn't.
When Gen Kayani was a three-star general, there was some disagreement between the two. He would never have risen further but for circumstances that forced Gen Musharraf's hand.
This was the period when Gen Musharraf and the PPP were negotiating the return of Benazir Bhutto, courtesy of the US. It was also the moment when Gen Musharraf was due to select a new vice chief, who would be his successor. This selection was of more than cursory interest to Mrs Bhutto, but it just so happened that Gen Kayani had served briefly on her staff when she was PM in her first tenure. Fate intervened to make him the chief.
As I expected, Gen Kayani was a great chief.
Within months of his appointment he had started welfare projects for rank and file soldiers, pulled all serving officers out of non-military appointments in government, and shuffled his divisional commanders. Not only did he raise morale among the ranks, but had restored the nation's respect for the army.
Challenged by the Swat-Taliban peace agreement in 2009, Gen Kayani supported the agreement even as I opposed it vehemently. My opposition was on principle; his support was based on pragmatism.
It turned out that he was right. Had the peace deal not occurred and had the Taliban not been given the opportunity to demonstrate to all doubters its sense of what constituted justice, perhaps the nation would not have united in support of military action against the Taliban.
When Gen Kayani sent forces into Swat, the American military was presumptuous enough to offer advice, which he spurned.
He personally planned the entire operation and even marked its outline on the map in his own hand. The monumental success of this operation stunned all sceptics, including the US military.
But Gen Kayani went much further. To rehabilitate young children who had been programmed as suicide bombers, he initiated the successful Sabaoon scheme (a Pashto word meaning "a ray of hope"). This programme was subsequently used in other locations, including Balochistan.
His next test was in South Waziristan. Again he passed with flying colours, despite the fact that US forces allowed many terrorists and their leader, Hakimullah Mahsud, to slip through their fingers.
To Gen Kayani's credit also lies the undisputable fact that on his watch, he made every endeavour to keep the army out of politics and, on the occasions that he felt bound to act, he did so softly, quietly and discreetly.
One day in early 2010 the media reported that in the just concluded Corps Commander's conference, the leadership had decided that the general should be given an extension. In the event, Gen Kayani got the extension; not just a year, but for three.
Where his first term was distinguished by his principled stand in serving the overall national interest on all issues, his second one was far less so. Being Gen Kayani, he could never do badly but he was certainly not doing as well as he had in his first term.
Perhaps he set the bar too high in his first three years and fatigue caught up in his second tenure. If so, it is understandable.
No one could thrive forever in this high-pressure assignment.
Gen Kayani was known to work up to 18 hours a day. The army too seems to have become fatigued.
Instead of the surgical operations in Swat and South Waziristan, it took almost a year to retake the Khyber Agency while operations in Kurram and Aurakzai agencies are continuing.
There are cogent military reasons for the prolonged operations in these three agencies, but perceptions are often more important than realities.
After three years, he could have left with an unblemished record. He is now, however, likely to leave with one that no longer shines as brightly as it once did.
There is one achievement of his which ran equally through both terms: he was doubtless the first army chief in Pakistan who determinedly and proactively supported the cause of democracy.
In that respect, his legacy is likely to be favourable. It is my considered view that the precedent Gen Kayani has set of nurturing democracy is likely to be followed. It deserves to be mentioned here that the entire environment which supported military takeovers, from the bureaucracy and politicians, to the judiciary has also changed, but so has the army, under Gen Kayani.
Brig Shaukat Qadir is a retired Pakistani infantry officer