ISLAMABAD—Pakistan's army chief said Saturday the country's powerful military supported negotiating with militants but would keep open the option of launching possible attacks against them.

The comments by Gen. Ashfaq Parvez Kayani, who rarely speaks in public but wields massive influence behind the scenes, supported the government's efforts while at the same time reminding people of the threat the militants still pose.

"The national leadership has chosen the way of giving peace a chance. The Pakistan army supports this process," Gen. Ashfaq Parvez Kayani said in a televised speech at a military academy in the northwestern city of Abbottabad.

The new government of Prime Minister Nawaz Sharif wants to negotiate an end to the violence that has killed tens of thousands in Pakistan. Under Kayani's tenure, the military has been engaged in a tough fight with the Pakistani Taliban and other militant groups that want to overthrow the government and install a hard-line Islamic state.

Kayani said the army would be happy if the talks lead to peace and that force is generally the last option. But Kayani warned that the military had the ability to confront militant with force if needed. He also reminded Pakistanis of the threat the militants posed back in 2008, before the army launched a series of major offensives in the tribal areas and the Swat Valley in Khyber Paktunkhwa province.

"We should remember those days when armed groups were 100 kilometers (60 miles) away from Islamabad, when women and men used to be butchered in bazaars," he said.

The army chief dismissed suggestions that negotiations were necessary because military operations have failed. Some Pakistan politicians have criticized the military operations, saying that Pakistan is essentially at war with its own people.

"One opinion has surfaced that perhaps the failed military operations forced for the negotiations," the general said. "It is far away from the truth."

Sharif's government appears to have made little progress in negotiating with the militants after a series of deadly bombings. Militants have demanded the government must free their prisoners and pull troops from the tribal regions where the militants have their strongholds for talks to take place. The militants also want an end to U.S. drone strikes.

Kayani is considered one of the most powerful people in Pakistan, but he'll be retiring next month. His successor has not yet been named.