WASHINGTON, Oct. 7 (CGTN) - President Donald Trump said Wednesday he wants all U.S. troops to leave Afghanistan by Christmas, speeding up the timeline for ending America's longest war.

"We should have the small remaining number of our BRAVE Men and Women serving in Afghanistan home by Christmas!" Trump wrote on Twitter.

Trump's remarks came hours after his national security adviser Robert O'Brien's indication that the United States will reduce its troops in Afghanistan to 2,500 early next year.

"When President Trump took office, there were over 10,000 American troops in Afghanistan. As of today there are under 5,000 and that will be reduced to 2,500 by early next year," O'Brien said earlier Wednesday at an event at the University of Nevada, Las Vegas.

A landmark deal between the U.S. and the Taliban in February said that foreign forces will leave Afghanistan by May 2021 in exchange for counter-terrorism guarantees from the Taliban, which agreed to negotiate a permanent ceasefire and a power-sharing formula with the Afghan government.

Trump and other officials have said that the United States will go down to between 4,000 and 5,000 troops in Afghanistan around November. Beyond that, officials have said that a reduction will depend on conditions in Afghanistan.

The White House's plan for the drawdown will almost certainly be subject to review should Trump lose his bid for a second term in next month's election.

Taliban and Afghan government-backed negotiators have agreed on a broad code of conduct to advance the intra-Afghan peace talks in Qatar, even as key differences between the two warring sides remain, Reuters reported on Wednesday, citing three official sources.

A ceasefire is a top priority for the Afghan officials and the western diplomats who are facilitating these talks. While the talks have been taking place in Qatar's capital Doha, scores of Afghan soldiers and Taliban fighters have been killed in clashes. Dozens of civilians have also died in recent weeks.

"Ultimately, the Afghans themselves are going to have to work out an accord, a peace agreement ... It's going to be slow progress, it's going to be hard progress, but we think it's a necessary step – we think Americans need to come home," O'Brien said.

About 2,400 U.S. service members have been killed in the Afghan conflict and many thousands more wounded.

Wednesday also marks 19 years since the United States invaded Afghanistan to topple the Taliban rulers who had harbored al-Qaeda militants who were behind the 9/11 attacks.