KABUL, Afghanistan – “We are in this to win,” Gen. David Petraeus said Sunday as he took the reins of an Afghan war effort troubled by waning support, an emboldened enemy, government corruption and a looming commitment to withdraw troops even with no sign of violence easing.

Petraeus, who pioneered the counterinsurgency strategy he now oversees in Afghanistan, has just months to show progress in turning back insurgents and convince both the Afghan people and neighboring countries that the United States is committed to preventing the country from again becoming a haven for al-Qaida and its terrorist allies.

“We are engaged in a contest of wills,” Petraeus said as he accepted command of U.S. and NATO forces before several hundred U.S., coalition and Afghan officials.

Petraeus, widely credited with turning around the U.S. war effort in Iraq, said the Taliban and their allies are killing and maiming civilians in an attempt to undermine public confidence in the Afghan government and the international community’s ability to prevail.

“In answer, we must demonstrate to the people and to the Taliban that Afghan and international forces are here to safeguard the Afghan people, and that we are in this to win,” Petraeus said.

Continual discussion about President Obama’s desire to start withdrawing U.S. forces in July 2011 has blurred the definition of what would constitute victory. That coupled with the abrupt firing of Petraeus’ predecessor, a move that laid bare a rift between civilian and military efforts in the country, has created at least the perception that the NATO mission needs to be righted.