ISLAMABAD (AP) — Pakistan's army chief Sunday ended speculation that he would try to stay on in what is often referred to as the country's most powerful position, announcing that he would retire when his term ends in late November.

Gen. Ashfaq Parvez Kayani has served two terms as head of the army at a time when it was mired in a vicious battle with Pakistani Taliban fighters at war with the state and fending off U.S. allegations that the military was supporting Afghan insurgents staging attacks against American troops in Afghanistan.

Kayani said in the statement issued Sunday by the military's public relations wing that his future plans had been widely discussed in the media.

"I am grateful to the political leadership and the nation for reposing their trust in me and Pakistan Army at this important juncture of our national history. However, I share the general opinion that institutions and traditions are stronger than individuals and must take precedence," he said.

"I have served this great nation and had the privilege of commanding the finest Army of the world for six years to the best of my abilities and with the sincerest of my intentions," Kayani said. "My tenure ends on 29th November 2013. On that day I will retire."

Kayani's tenure was marked by a peaceful transfer of power from one civilian government to another, a first for a country that has been dominated by a powerful military for most of its history.

The general was credited with publicly staying out of politics although the army continued to play a powerful role in the background, especially with regard to policy toward the Afghan war, U.S. relations and relations with Pakistan's neighbor and archenemy, India.

Relations with the U.S. were severely tested by several episodes during Kayani's tenure including the covert American raid that killed Osama bin Laden near Pakistan's equivalent of West Point in 2011.

Kayani and other officials were outraged by the operation because they were not told about it beforehand and curtailed military and intelligence cooperation with the U.S.

American officials expressed disbelief that Pakistan didn't know the al-Qaida chief was hiding in the town of Abbottabad. The U.S. never uncovered evidence indicating Kayani or other senior officials knew bin Laden's whereabouts, but suspicions about Pakistan's loyalties remained.

During his tenure, Pakistan also launched numerous operations against militants in the tribal areas that have been waging war against the Pakistani state. Those operations sparked fierce retaliation by the militants against both civilian and military targets, and thousands of troops have been killed and wounded.

Despite the army's efforts, however, violence has continued. Dealing with the insurgency will be a key task for the country's next army chief, who will be appointed by Prime Minister Nawaz Sharif.

The appointment will be a challenge for Sharif, who has had a rocky relationship with the military. He was deposed as prime minister in 1999 by Gen. Pervez Musharraf, the man that Kayani succeeded as army chief in 2007.

The new army chief will also face an uprising by separatists in Pakistan's southwestern Baluchistan province as well as heightened tensions along the de-facto border that separates the Pakistani- and Indian-held sides of the disputed region of Kashmir.