The BBC has gained new evidence showing why Pakistan's security establishment is now taking such a hard line against the country's various extremist organisations.
British-born Omar Sheikh is said to have built up a network of jihadis
Nine people - a military commando and eight civilians - are currently facing a court martial in Pakistan for attempting to assassinate President Pervez Musharraf.
They are accused, among other things, of plotting a suicide attack against the country's military leader on 25 December 2003.
The attack in the garrison town of Rawalpindi left 11 dead - Gen Musharraf escaped unharmed.
The in-camera trial at the scenic and historic Attock Fort in northern Punjab has revealed some startling facts surrounding the relationship that once existed between Pakistan's powerful military establishment and the so-called jihadis (holy warriors).
These revelations may prove to be a watershed for a relationship that has survived many ups and downs over the past 20 years or so.
One name has kept cropping up, even though he is not on trial.
He is the British-born Islamic militant Ahmed Omar Saeed Sheikh - in jail for the last three years and currently contesting a conviction for the murder of Wall Street journal reporter Daniel Pearl.
Omar Sheikh has probably not been put on trial in this case because he was already under arrest by the time the attacks on President Musharraf were carried out.
But according to much of the evidence presented by the state at the court martial, he emerges as the person who conceived of the idea of eliminating the Pakistan president because of his pro-America policies.
There have been six attempts on Musharraf's life
In the period before his arrest for Daniel Pearl's murder, it appears that Omar Sheikh may have been among the most active anti-US militants in Pakistan.
Recruiting for his cause
The court martial has been told that Sheikh had focussed mainly on "recruiting" trained army commandos into his network of militants.
His job was to convince the commandos to place their loyalty first to his group of holy warriors, rather than the military.
Apparently, he succeeded to the extent that two low-ranking members of the elite commando force agreed to join him in his campaign to eliminate President Musharraf.
One of them - Naik Arshad Mahmood - is among the nine facing court martial.
But the other commando, Zafar Iqbal Dogar, is now a key prosecution witness.
According to Dogar's testimony, Omar Sheikh was the master-planner of the initial plot to assassinate President Musharraf.
Dogar claims to have first met Omar Sheikh in early 2001.
Along with a few other Islamists, Sheikh was visiting a military training facility in Rawalpindi posing as a member of an Islamic missionary group called the Tablighi Jama'at.
Pakistan's Tablighi Jama'at is one of the largest Muslim missionary groups in the world and its members were apparently invited to army garrisons on a regular basis on preaching assignments.
What they do believe is that Omar Sheikh was apparently quite successful in bringing together an entire network dedicated to killing President Musharraf
Omar Sheikh subsequently held several meetings with the two commandos, the most important of which was the one held immediately after the US attacked Afghanistan in 2001.
Dogar told the court that the meeting - convened by Sheikh and attended by about 25 extremists - marked the beginning of the campaign to kill the president.
The 25 men were asked by Sheikh to take a pledge to work for the destruction of the US and its allies including President Musharraf, the court martial heard.
Dogar says in the first few months after the meeting, Omar Sheikh even supervised the collection of weapons and explosives for the attacks.
It is not clear if he remained in contact with this group after his arrest in 2002.
But once the suspects of the December 2003 plot were arrested, Omar Sheikh was brought from his prison in the southern town of Hyderabad to Rawalpindi for questioning.
But he refused to co-operate. In fact, senior officials admit that since the day of his arrest, even the best interrogators have been unable to get anything out of him.
Musharraf was targeted because of his growing ties with the US
But what they do believe is that Omar Sheikh was apparently quite successful in bringing together an entire network dedicated to killing President Musharraf.
This network includes various militant groups, members of the armed forces, gun runners from Pakistan's tribal areas and militants directly working for al-Qaeda.
The links have come as a real eye opener for the country's security establishment.
Many of the militants were once nurtured and protected by the authorities, as they were fighting against Indian forces in Kashmir.
It had apparently taken the authorities quite a while to discover that they had now turned their guns against Pakistan's rulers.
Many observers argue that the discovery of this turnaround within the jihadis - which led to six attempts on the president in less than two years - may have played a decisive role in changing the establishment's mindset towards the militants.
Pakistani security forces have busted several gangs of Islamic extremists in recent years.
But no one can say with authority that the threat to Pakistan's current leadership is over.
It is perhaps only now that they are beginning to comprehend the grave import of Omar Sheikh's reaction to his conviction in Pearl's murder.
Omar Sheikh had reportedly described the trial a "waste of time" in a "decisive war between Islam and the infidels".
"I will see whether those who want to kill me [succeed] or get killed first," he had said as the verdict was announced.