Armed residents beat back a Taliban incursion into a town in the strife-torn Swat Valley on Thursday, a local official said, adding to reports that local uprisings are aiding Pakistani security forces' efforts to overtake militant strongholds. While the Taliban never gained broad public support among Swat's population of 1.5 million, the Islamist extremists were able to gain sway in the valley in recent months and began to impose their harsh version of Islamic justice, relying on threats, force and the free rein granted by a government truce. But with the collapse of the peace deal, residents have become emboldened by a Pakistani assault that has put the militants on the defensive and forced many of them to retreat and go into hiding. Hundreds of armed residents of Kalam, a picturesque mountain town of about 50,000 people, came out to fight about 50 Taliban fighters who tried to enter, said the town's deputy mayor, Shamshad Haqqi. He said several militants were killed or captured amid intense fighting. Residents of the town, a former tourist resort at an altitude of about 10,000 feet, have fought off Taliban attacks several times in the past. "We will not allow Taliban to come here," said Mr. Haqqi. The residents called for the army's support as they feared more insurgent attacks, but it was unclear if troops were sent. Residents in many other areas have formed local militias to resist the Taliban, boosting the military's effort to crush the group, says Maj. Gen. Athar Abbas, the chief military spokesman. The Taliban received a major setback when government forces seized control of the town of Matta on Wednesday, driving out the militants from one of their strongest holdouts in Swat. Some 15,000 troops have been fighting an estimated 5,000 militants in what is described by Pakistani leaders as a battle for survival of the country. The fighting has forced some two million people to flee their homes, triggering the nation's most severe humanitarian crisis. A Pakistani military spokesman said Thursday that five soldiers and a number of militants including a senior rebel commander were killed in fighting as troops, aided by fighter jets and helicopter gunships, pressed on against the insurgents. According to the military, more than 1,050 militants and more than 60 soldiers have been killed since government forces launched their offensive. A Taliban spokesman couldn't be reached to comment.