Pakistani forces say they have regained full control of Mingora, a week after re-entering the main town in the Swat valley to dislodge Taliban fighters.
Military spokesman Major-General Athar Abbas told a news conference that medical teams and food supplies had arrived in the town, which had been cut off since the start of the month.
Gas supplies have been restored, but the electricity grid needs to be repaired and it may take up to two weeks for amenities to be fully restored, according to Gen Abbas.
Around 300,000 people had lived in Mingora until the Taliban occupied the town in early May when the army first launched an offensive in Swat.
The security forces have secured an area of up to 70km north of Mingora, including the town of Bahrain, the general said.
He told Reuters shortly before the news conference that some militants were still putting up resistance on Mingora's outskirts.
He said 1,217 militants had been killed since the fighting began in late April, while 81 soldiers had been killed, and 250 wounded.
There are no independent casualty estimates available.
The UN has pleaded for international support for a $543m fund to help Pakistan cope with the level of refugees from the conflict area.
An estimated 1.7m people have left their homes to flee the fighting.
Almost 90% of the displaced people have been offered shelter by families in neighbouring peaceful areas, while the rest have headed for makeshift camps around towns like Mardan and Swabi.
There are fears of disease breaking out as summer temperatures soar on the plains below the mountains of the northwest.