By Phil Stewart

KABUL (Reuters) - The United States will keep up to 1,000 more soldiers than previously planned in Afghanistan into next year, outgoing U.S. Defense Secretary Chuck Hagel said on Saturday, in a recognition of the still formidable challenge from Taliban insurgents.

Hagel, confirming a change in the U.S. drawdown schedule first reported by Reuters in November, said the additional forces were needed because delays in signing security pacts had impacted plans to raise troops from other countries.

However, he also said that a particularly violent surge of Taliban attacks in Kabul in the last two weeks was a reminder of the continued need for a foreign presence.

"The recent wave of Taliban attacks has made it clear that the international community must not waver in its support for a stable, secure and prosperous Afghanistan," said Hagel, who arrived in Kabul unannounced on Saturday morning.

The NATO-led combat mission in Afghanistan officially ends in two weeks with a sharp reduction in western forces, but troops that stay behind will still provide "combat enabler" support to Afghan soldiers, Hagel said.

The United States will also maintain a mission to fight al Qaeda in the country, he added.

"We have not forgotten what brought America to Afghanistan over a decade ago," Hagel said at a joint press conference with Afghan President Ashraf Ghani.

"And we will take appropriate measures against Taliban members who directly threaten U.S. and coalition forces in Afghanistan or provide direct support to al Qaeda."

Gen. John Campbell, the commander of international forces in Afghanistan, said last week the ongoing U.S. role would include limited air support to Afghan soldiers.

Hagel, who resigned last week under pressure, said U.S. forces could fall only to 10,800 troops, rather than 9,800 as originally planned. The additional troops could stay until the first few months of 2015.

"But the president's authorization will not change our troops' missions, or the long-term timeline for our drawdown," Hagel said on his last trip to the country as Pentagon chief.

Story continues

He appeared confident that the United States would secure support from NATO allies in the next few weeks that would allow U.S. force levels to drop back to 9,800.

BLOODIEST YEAR

Hagel's visit followed the bloodiest year in Afghanistan since the war against Taliban militants began in 2001.

As of early November, about 4,600 members of the Afghan security forces had been killed in 2014, more than 6 percent higher than the same period of 2013.

Even as U.S. officials including Hagel praised the accomplishments of Afghan forces, the high rate of Afghan casualties is seen as unsustainable and has raised questions about their vulnerability as foreign troops dwindle.

Earlier, Hagel expressed confidence in the ability of Afghan forces to defend Kabul following the spike in attacks.

U.S. President Barack Obama's drawdown strategy has attracted criticism, including from Republicans in Congress, who say gains against the Taliban could be lost in much the same way that violence returned to Iraq after the U.S. withdrawal.

Hagel warned against drawing comparisons between Iraq and Afghanistan, saying Afghans want U.S. forces to stay.

"Are there (security) gaps? Are there continued challenges? And threats? Absolutely," Hagel acknowledged, noting Afghanistan would still struggle with "pockets" of Taliban resistance.

The Taliban have become increasingly bold in their attacks and control several districts across a country where access to many areas is still limited by rugged terrain and poor security.

(Editing by Frank Jack Daniel and Clelia Oziel)