Kayani, set to retire next month after leading the army for six years, said the military fully backs the government's move to hold talks with militants.
There is an opinion that the government was forced to go in for talks because of the failure of military operations against militants but this is far from the truth, he said while addressing a passing-out parade at the Pakistan Military Academy in Abbottabad.
Describing terrorism as a "big challenge" that goes against Pakistan's ideology and Islamic teachings, he said: "To deal with it, the national leadership chose the option of giving talks a chance. The Pakistan Army supports this move.
"The nation and the political leadership have to decide the limits for these talks...It is very important that this process leads to unity among the people and not divisions. It is necessary to find a solution to this problem within the Constitution of Pakistan."
Prime Minister Nawaz Sharif offered talks to the Pakistani Taliban after assuming office in June, a move that was endorsed by the country's main political parties last month.
However, the Taliban responded by killing a top general in a roadside bombing and setting preconditions for talks, including the withdrawal of troops from the tribal areas.