General Ashfaq Parvez Kayani said on Saturday that he supports peace negotiations with Islamist Taliban rebels to end more than 10 years of insurgency in the country.

Pakistan Prime Minister Nawaz Sharif last month announced plans to stage talks with the militants, who have killed more than 40,000 people in a ruthless wave of bombings and gun attacks during the last decade.

“(The) Pakistan army will be happiest of all if a negotiated solution is found of this problem,” he told a graduation ceremony of newly inducted army officers.

But he cautioned that any solution to the militancy should adhere to the country’s constitution.

Gen. Kayani, who is retiring next month after leading the army for six years, said that force should be used as last resort. He also said that his troops were ready and well prepared to deal with the rebels if talks failed.

He reminded that, at one point, the militants were just 100 kilometers away from the capital, Islamabad, but that the army pushed them back by launching an operation in Swat, in the country’s North-west, in 2009.

His statement came after reports in the media that the army was opposed to the government’s push for a peace process.