Mr Gilani said the government had to take decisive steps
Pakistan's PM says he has ordered the army to "eliminate militants and terrorists", apparently referring to operations against the Taleban.
Yusuf Raza Gilani made the announcement in an evening TV address to the nation.
Fighting has intensified in recent days in the Swat Valley and other parts of the north-west, and thousands of civilians are leaving the area.
Meanwhile US envoy Richard Holbrooke said there had been progress in getting Pakistan and Afghanistan to co-operate.
"I hope the American public sees that we're making progress in the question for real cooperation between Afghanistan and Pakistan, because without that cooperation, success is not achievable," Reuters news agency quoted him as saying.
Zardari and Karzai on meeting
Mr Holbrooke was speaking after a meeting with Afghan President Hamid Karzai, Pakistani President Asif Ali Zardari and US senators.
He said another summit would be held between the Afghan and Pakistani leaders and US President Barack Obama after Afghan presidential elections in August. The three leaders met on Wednesday.
Mr Zardari said the international community was coming to the realisation that the problem of militancy in Pakistan and Afghanistan was a worldwide one.
Earlier US defence secretary Robert Gates said he was satisfied with Pakistan's anti-Taleban moves.
He said there was "very little chance" of the Taleban achieving the kind of success in Pakistan that they would need to get access to the country's nuclear weapons.
At least 10 soldiers have been killed and nine wounded in the fighting in the past 24 hours, the Pakistani military says.
Mr Gilani said efforts by the militants to disrupt peace and security had reached a point where the government had to take "decisive steps".
"In order to restore honour and dignity of our homeland, and to protect people, the armed forces have been called to eliminate the militants and terrorists," he said.
"The time has come when the entire nation should side with the government and the armed forces against those who want to make the entire country hostage and darken our future at gunpoint," he added.
He also appealed to the international community to help Pakistan look after people displaced by the fighting.
A curfew has been lifted to allow civilians to leave Swat, prompting thousands to flee and join those already in camps or staying with relatives further south.
But around half a million people remain in Mingora, the main town of Swat, where there is no water or electricity.
Residents say at least 24 civilians have lost their lives in the past two days.
Some died when their houses were hit by artillery, while others were reportedly shot for defying a curfew.
The BBC Urdu service's Riffatullah Orakzai says that eyewitnesses in the Kanju area near Mingora have seen militants setting up checkposts on the main roads and not allowing people who want to flee the fighting to pass.
Witnesses say a large number of people, including women and children, are now stranded there.
Resistance to troops
The International Committee for the Red Cross (ICRC) says the humanitarian crisis in Pakistan is intensifying.
In a statement the ICRC said that it no longer had access to the areas most affected by the conflict and that precise statistics of the displaced were difficult to ascertain.
The BBC's M Ilyas Khan in Islamabad says troops moving into Swat face resistance all along the 40km (25-mile) road that heads in a north-easterly direction from Malakand to Mingora.
Our correspondent says that fighting has not only erupted in several areas around Mingora, but there are also reports of more clashes in the neighbouring area of Buner.
In another incident, militants overran a paramilitary fort in the Chakdara area of Lower Dir, officials say.
Three paramilitary soldiers were killed in the attack and 10 policemen were taken away as hostages.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.