Pakistan's Lieutenant-General Raheel Sharif attends a military exercise in Khairpure Tamay Wali in Pakistan's Bahawalpur district. Reuters
Just after midnight in early October, Pakistani prime minister Nawaz Sharif and a coterie of his closest advisers met at his palatial Lahore home and made his toughest decision since coming to power - picking the new army chief.
The meeting took place only hours after Pakistan's all-powerful army chief General Ashfaq Kayani suddenly announced he would retire in November, scotching rumours he was seeking to extend his tenure.
Sharif saw Kayani's departure as a chance to limit the sway of an institution that has ruled Pakistan for more than half its 66-year history.
He immediately sat down with his top aides to choose a successor, an insider with first-hand knowledge of the event told Reuters.
"We have to say 'no' to the Kayani doctrine," the insider quoted Sharif as saying at the meeting. "(Sharif) and the three others in the room all agreed that it was time to show the world that this was no longer Kayani's army."
Lieutenant-General Raheel Sharif, considered a rank outsider in the race for army chief, is due to take charge of the world's sixth-largest military in a ceremony on Friday.
The decision was announced on Wednesday, and came as a shock to those familiar with the country's politics. Not only did Sharif choose to bypass Lieutenant-General Haroon Aslam, the most senior military officer after Kayani and thus his natural heir, but he also ignored Kayani's personal favourite, Lieutenant-General Rashad Mahmood.
Pakistan's new army chief General Raheel Sharif (R) and outgoing army chief General Ashfaq Kayani attend the change of command ceremony in Rawalpindi. AFP Photo
Raheel Sharif, 57, is known as a laid-back man with a fondness for cigars and an almost complete lack of political ambition.
His father, a retired major, ran one of the country's most exclusive country clubs in Pakistan's cultural capital, Lahore, ensuring a connection with Nawaz Sharif, who has long been one of the most important members of the city's upper classes.
Most importantly, Raheel Sharif, who is no relation to the prime minister, has twice served under tribal affairs minister Abdul Qadir Baloch, a retired general and one of Nawaz Sharif's closest confidants.
Baloch was at the Lahore meeting when Raheel Sharif's name was finalised for the top job.
Sharif knew, however, that he could not entirely overrule Kayani, the quiet, chain-smoking general, who at one point was voted by Forbes magazine as the 28th most powerful man in the world.
Kayani had favoured Mahmood for the post. So Sharif chose a compromise aimed at placating Kayani loyalists. He appointed Mahmood chairman of the Joint Chiefs of Staff Committee, technically the country's highest military office but historically subservient to the army chief.
Read More: Will history repeat itself in Pakistan?
Raheel Sharif will at times have to defer to Mahmood, his nominal boss, given his lack of experience in the intelligence service or the Military Operations Directorate, two traditionally powerful areas.
The decision to appoint a Kayani loyalist as joint chiefs chairman is a political concession that will make or break Sharif's term as the prime minister of the coup-plagued South Asian nation, retired military officers and analysts said.
General Raheel Sharif on November 29 formally took over as the head of Pakistan's army, the most powerful position in the troubled military-dominated nation which is battling a homegrown Taliban insurgency. AFP photo
It is an attempt to appease the generals while also allowing the balance of power in the country to swing toward the civilian government for the first time in more than a decade, said military affairs expert and author Ahmed Rashid.
"Politicians here have a tendency to think that lesser known generals are more manageable generals," he said. "Raheel (Sharif) has not been on the radar at all. He doesn't have a public persona in the way that the other front-runners do."
For a prime minister determined to wrest control of strategic and foreign policy from the army, appointing Mahmood, a man moulded in Kayani's image, who would come to the job with his own ideas, would have been less than ideal.
As one retired air marshal said: "Appointing Mahmood would have meant another three years of Kayani's thinking. It was a no-brainer."