Pakistani troops fighting street-by-street with Taliban militants have regained control of more than half of the largest town in the Swat valley, and many insurgents were now fleeing the battlefield, military commanders said Tuesday.

The militant threat has made Pakistan's Western allies increasingly anxious to see political stability in the country — a goal that may be helped by a top Pakistani court's decision Tuesday to lift an election ban on opposition leader Nawaz Sharif, the country's most popular politician according to polls.

The ruling removes a source of uncertainty and possible political conflict in the country as it battles Taliban insurgents spreading out across the nuclear-armed nation from the lawless northeast.

Sharif is now free to contest national elections in 2013 and become elected to parliament in a by-election. He had been blocked because of a criminal conviction in 2000 he has insisted was politically motivated.

Officials said the military's monthlong offensive was advancing in the Swat valley, where a growing humanitarian crisis is adding pressure to the government, which is being tested in its resolve to stand up to the militants.

The U.N. High Commissioner for Refugees on Tuesday said nearly 2.4 million people have been uprooted by the violence, with people being forced from their homes at a rate of about 126,000 people day — one of the sharpest rates of displacement in recent world history.

The numbers were being cross-checked for accuracy, but there was no immediate sign that conditions were improving, UNHCR spokesman Ron Redmond said in Geneva.

And Human Rights Watch warned that a curfew keeping thousands of residents trapped in the valley in their homes for long periods risks causing a humanitarian catastrophe because food, water and medicine is running out.

Pakistan army chief spokesman Maj. Gen. Athar Abbas gave an upbeat assessment Tuesday of the campaign, which is strongly backed by U.S. officials who want Pakistan to root out al-Qaida and Taliban havens used to plan attacks on Western troops in nearby Afghanistan. Swat is considered an important test of the Muslim nation's ability and willingness to do so.

"The information we have so far from intelligence and other sources is that militants' moral is down, they are panicked and they are trying to flee from different parts" of the valley, he said.

Only "hard-core" militants were left, with most local recruits giving up their arms and returning to their communities, he said.

The army was in control of more than half of the main city of Mingora, though militants were putting up stiff resistance in the rest.

"All the intersections and squares, most of them are in our control, and escape routes for them have been choked," he told a media briefing.

Intense fighting was also under way in Kabbal, in the north of the valley.

The military says about 1,100 suspected insurgents have died so far in the offensive, and civilian casualties have been kept to a minimum. It is not possible to confirm the numbers, as journalists have largely been kept out of the area. But witnesses have described widespread civilian casualties.

In the south of the country, troops fought suspected militants Tuesday in South Waziristan, in the restive tribal belt between Afghanistan and Pakistan where U.S. and other officials believe the Taliban and al-Qaida have strongholds.

Officials fear an even greater refugee crisis if large numbers of residents in other regions start fleeing.

Abbas said Tuesday's fighting was not part of an ongoing military operation in Waziristan, but security forces had repulsed a militant attack on one fort and extended a security perimeter at another.

Intelligence officials said Pakistani troops backed by helicopter gunships attacked suspected militant hide-outs in Siblatoi and Chakmali villages in South Waziristan, killing at least six insurgents and wounding 12 others. The two officials spoke on condition of anonymity because they were not authorized to speak on the record to reporters.

Syed Mohsin Shah, the top government official in nearby Dera Ismail Khan district, said some 1,500 families have fled from South Waziristan in the past few weeks because of the fighting.