For decades, Pakistan concentrated most of its military assets against India on the eastern frontier. Its western frontier, or the border with Afghanistan and Iran, remained quiet and left to local tribes who guarded their territory, often rising up in arms whenever threatened by an outside force.
The western border is also Pakistan's longest, running almost 2,600km from the Gilgit Baltistan in the northwest down to Baluchistan province - roughly the flying distance between Moscow and London.
Despite the vastness of this border, a standing military presence was not needed there, other than scouts or paramilitary forces or regular police forces.
However, this changed during the US-led invasion of Afghanistan after the September 11, 2001, attacks, specifically with a major operation in the Tora Bora Mountains against al-Qaeda when Pakistan deployed their forces for the first time in the tribal areas.
The American-led coalition forces wanted Pakistan's military to act as the anvil as they pushed al-Qaeda fighters out of their positions high up in the snow-capped mountains.
At the time, General Orakzai, the top military man for the northwest frontier, told me in Peshawar that the army was moving into the Federally Administered Tribal Areas (FATA) to ensure that Pakistan's western frontier could be secured.
If large numbers of fighters came into this territory, the Afghan war could spill over into Pakistan, like the Vietnam War spilled into Cambodia.
Tribes had volunteered to fight alongside Pakistan's army against the Indian forces in Kashmir, and while they did not want to stop the army from securing the border, their loyalties were divided.
Fellow tribesmen across the border were seen to be fighting against what they believed to be an occupation force, even though the US had stated that its mission was to kill or capture its number one enemy – Osama bin Laden – and dismantle al-Qaeda.
Even though the border was clearly defined, contiguous tribes and sometimes even villages, were divided in two in one house in the Khyber, a room was in Pakistan and the courtyard in Afghanistan.
Deployment along the western border was also problematic and brought the Pakistan military in a direct confrontation with al-Qaeda.
Even though Pakistan brought in over a 120,000 troops to this frontier, neither the Afghan National Security Forces (ANSF) nor NATO forces beefed up border security.
Instead they concentrated more on the populated centres when US General Stanley McChrystal used a "surge strategy" perfected in Falluja, Iraq, making the border even more vulnerable to infiltration.
Once on the Afghan side you could travel all the way to Kabul and beyond or find sanctuary elsewhere. Despite the sizeable presence of the Pakistan army, most tribal areas realised soon after the Swat operation in 2009 that the bulk of Swat Taliban chief Mullah Fazlullah's fighters could escape through upper Dir.
For months no one knew what happened to Fazlullah and rumours circulated about his capture in Pakistan. Afghan intelligence even said he had been killed in action against a US military base in Nooristan. This was far from the truth.
Pakistan alleged that Fazlullah was getting help from the Afghan government and had the direct support of the governor of Kunar province.
Within a year of after his escape from Swat, Fazlullah finally came out with a video message showing him besides his regrouped and newly funded fighters, now well armed and in what to be Nuristan province across the border in Afghanistan.
As time went by, Fazlullah's assassins killed people at will in deliberate target killings across Swat and Dir.
He sent letters to the locals warning them of punitive action and sent death threats to the local landlords, warning them of the dire consequences for supporting the government.
His men went on to attack the border town of Nustrat Darra in retaliation against their refusal to let Fazlullah use their village as a main base of operation.
However, the locals put up a stiff resistance and for months guarded this key strategic patch of territory.
In one incident, dozens of policemen were gunned down. Despite the fact that they surrendered, the policemen were brought to Nustrat Darra's main school and brutally shot with both rockets and bullets. Weeks later, 28 men of the Chitral scouts were attacked at their posts and killed.
Enough was enough.
Pakistan's military chief went to Chitral and last year and asked his troops to secure an almost 500km stretch of the border all the way to Dir, which was previously unguarded except for a few paramilitary posts.
However, as the attacks from Fazlullah's men increased, the military brought in fresh troops to reinforce this increasingly hostile border.
Just recently my team and I had a rare privilege to go to Nustrat Darra with help from the Pakistan army.
For years the defence of this territory was the domain of the locals. But now the military is here for the first time since independence to secure this patch of the border with Afghanistan and provide a buffer to ease the burden on the locals who played a pivotal role in securing this stretch of territory.
We could see that the military's presence had helped people return to their everyday livelihoods. The carpenters were back at work and the local police was once again on the streets of Nustrat darra and Barawal town close by.
However, all is not well.
The Afghan frontier was just a few hundred metres away from us and covered in thick pine forests . Just weeks ago, a Pakistani military patrol had been ambushed by hundreds of Fazlullah's fighters and taken away. They were then beheaded before being returned to Pakistan. The carnage was taped on video and circulated to local tribesmen by the Swati Taliban.
As the sun went down on Nustrat Darra recently, we joined the army to break the Ramadan fast. Even though the men looked determined to hold on to their new posts, they knew they had a difficult, if not impossible, task ahead of them.
Pakistan had now deployed up to 40,000 fresh troops on its border from Chitral down to Dir, and was also under pressure to launch a major push in North Waziristan. But before it could do that, it would need to plug the gaps to secure its border frontier.
Fazlullah does not call the shots here anymore, but his fighters are still determined to keep up the pressure on the Pakistani security forces.