Updated

Defense Secretary Chuck Hagel arrived in Afghanistan Friday for his first visit as Pentagon chief, saying that there are plenty of challenges ahead as NATO hands over the country's security to the Afghans.

"We are still at war," Hagel said, warning the U.S. and its allies to remain focused on the mission while noting that the U.S. never intended to stay in Afghanistan indefinitely.

"That transition has to be done right, it has to be done in partnership with the Afghans, with our allies," said Hagel, who took over the Pentagon job a little more than a week ago. "Our country as well as Afghanistan, the region, and the allies have a lot at stake here. And our continued focus and energy and attention on Afghanistan is going to be very important."

He said it was vital to remember why the U.S. invaded Afghanistan in the days after the 9/11 attacks, including the need to rid the country of terrorists and a hostile government.

Hagel told reporters traveling with him that he plans to talk to Afghan President Hamid Karzai about the recent order expelling U.S. commandos from Wardak Province. He would not say what his message to Karzai might be.

Karzai ordered that U.S. special operations forces leave within two weeks because of allegations that Afghans working with the commandos were involved in abusive behavior and torture.

The order comes despite worries that it could leave the region more vulnerable to al-Qaida and other insurgents. U.S. officials have said they have seen no evidence that American forces were involved in the abuse of Afghan civilians.

Hagel is slated to meet with U.S. commanders and Afghan leaders and plans to make his first detailed assessment of the increasingly unpopular war.

His unannounced visit comes at a turning point in the conflict, as U.S. and NATO allies set their timetable for the withdrawal of combat troops and pressure mounts on the U.S.-led effort to train the Afghan forces. Hagel must manage the transition as the U.S. steps up what will be a difficult and expensive extraction of equipment from the country even as Congress slashes billions of dollars from the defense budget.

"I need to better understand what's going on there," Hagel told reporters during the flight to Kabul. He said he wants an assessment on the progress of the Afghan forces as they prepare to take over the security of their own country.

Hagel traveled to Afghanistan four times during his two terms as senator for Nebraska, including once in 2002 shortly after the war began, in 2006 and twice in 2008. His final two visits were in 2008, once in February with then Sens. Joe Biden and John Kerry — now the vice president and secretary of state, and in July with then-Sen. Barack Obama.

While Hagel initially supported the Afghanistan war when he was senator, his enthusiasm diminished as the conflict dragged on for more than 10 years. He pointedly observed that militaries are "built to fight and win wars, not bind together failing nations." And in a radio interview this year, he acknowledged the nation's growing weariness with the war that has claimed the lives of more than 2,000 U.S. troops and wounded another 18,000, saying that "the American people want out" of Afghanistan.

His review of the war will likely be colored in part by his own military service. Hagel is the first Vietnam veteran to lead the Pentagon, and the first man to become defense secretary after serving only in the enlisted ranks. All the other secretaries with military service eventually served as officers. Hagel served in Vietnam alongside his brother, was wounded twice and was awarded two Purple Hearts.

There are currently about 66,000 U.S. troops in Afghanistan, down from a peak of about 100,000 in 2010. The U.S. troop total is scheduled to drop to about 32,000 by early next year, with the bulk of the decline coming over the winter months.

And, while there has been no final decision on the size of the post-2014 force, U.S. and NATO leaders say they are considering a range between 8,000 and 12,000. The size of that residual force is sharply smaller than what the top U.S. commander in the Middle East recommended. Gen. James Mattis, head of U.S. Central Command, told the Senate Armed Services Committee earlier this week that his personal recommendation was for a U.S. force of 13,600, with the expectation that NATO allies would contribute another 6,000 to 7,000.

Hagel would not say what his assessment of the final post-2014 numbers is yet. But, he added that, "it is the Afghan people who need to make, and will make, their own decisions about their future. We can help. We have helped, as well as our allies. But there does come a time when that should be transitioned."

And the transition, he said, is happening in a way that give the Afghan people "a very hopeful future."

The U.S. is currently in the early stages of negotiating a bilateral security agreement with Kabul that would set the legal parameters for America's continued military and diplomatic involvement with the nation.

Another source of anxiety among the allies is Afghanistan's 2014 presidential election; Karzai, who has led the country since U.S. forces toppled the Taliban in late 2001, is not running and there is no obvious successor.