Addressing a media conference in the capital Islamabad, the prime minister said the government had achieved its military targets in Malakand and people displaced by the conflict could begin returning to their homes from 13 July.
“We have achieved the targets,” the prime minister said.
However prime minister Gillani made it clear that the army would remain in the area even at the end of the operation.
Aid agencies including the United Nations estimate more than two million civilians have been displaced by the fighting.
Gillani said that the war against extremists was Pakistan's war, and the Pakistani military would remain in some parts of Malakand to ensure security.
He said extremists had disgraced the Muslim shrines and had slaughtered children while challenging the writ of the government.
Gillani said the government would continue to pursue its policies of fighting militants and termed recent US drone attacks as counterproductive.
“We don’t need to convince them, but if they really want to help us, they should stop the drone attacks.”