Updated

President Obama announced Tuesday that he aims to keep 9,800 U.S. troops in Afghanistan after the war formally ends later this year, while pledging a near-total withdrawal by the end of 2016.

[audio-clip]

"This year, we will bring America's longest war to a responsible end," Obama said, in remarks from the Rose Garden.

The long-anticipated withdrawal plan is largely in line with what military commanders have been seeking and would allow the president to fully end the American-led military effort by the time he leaves office.

The plan would shrink the U.S. troop presence from its current force of 32,000 to 9,800 by the start of next year, and to roughly half that size by the end of 2015. Nearly all those forces are to be out by the end of 2016, as Obama finishes his second term.

"It's time to turn the page," Obama said. If the U.S. troop presence in Afghanistan indeed lasts through 2016, that would bring the length of the U.S. engagement in Afghanistan to 15 years. Afghanistan is already the longest U.S. war.

The president, though, faced criticism from Republicans on Tuesday for setting a firm withdrawal table.

Sens. John McCain, R-Ariz.; Lindsey Graham, R-S.C.; and Kelly Ayotte, R-N.H., warned that success in Afghanistan would be difficult if the U.S. is giving its enemies a "date certain" when troops will leave.

"The president's decision to set an arbitrary date for the full withdrawal of U.S. troops in Afghanistan is a monumental mistake and a triumph of politics over strategy. This is a short-sighted decision that will make it harder to end the war in Afghanistan responsibly," the senators said in a joint statement.

House Armed Services Committee Chairman Buck McKeon, R-Calif., praised Obama Tuesday for honoring the military's request to keep some forces in Afghanistan -- but also questioned whether a strict timetable should be set.

"Holding this mission to an arbitrary egg-timer doesn't make a lick of sense strategically," McKeon said in a statement, suggesting this would "replicate" the mistakes from Iraq.

In Iraq, the administration failed to strike a broader security agreement with Baghdad and pulled out nearly all U.S. troops, which some blame for chaos in the country now. "We are in Afghanistan because it was the spawning ground of Al Qaeda and the devastating attack on American soil. Those threats still exist," McKeon said. "We leave when the Afghans can manage that threat, rather than on convenient political deadlines that favor poll numbers over our security."

In pointed terms, however, Obama said Tuesday that "this is how wars end in the 21st century."

He said the U.S. will stay "committed" to a stable and secure Afghanistan, but added: "Afghanistan will not be a perfect place, and it is not America's responsibility to make it one."

The two-year plan is contingent on the Afghan government signing a bilateral security agreement with the U.S. While current Afghan President Hamid Karzai has refused to sign the agreement, U.S. officials are confident that either of the candidates seeking to replace him will give his approval.

Over the course of next year, the number of troops would be cut in half and consolidated in the capital of Kabul and at Bagram Air Field, the main U.S. base in Afghanistan. Those remaining forces would largely be withdrawn by the end of 2016, with fewer than 1,000 remaining behind to staff a security office in Kabul.

Obama revealed the plans after returning from a surprise weekend trip to Afghanistan where he met with U.S. commanders and American forces serving in the closing months of the nation's longest war.

The administration was also dealing with a potential security problem that arose from that visit, after his press office inadvertently revealed the name of the CIA station chief in Afghanistan. The name was included Sunday in a list of senior officials who met with the president -- the White House later sent out a corrected list without the CIA official's name, but the list had already been circulated at that point. It's unclear whether the administration will have to take any additional security precautions over the incident.

Ahead of his remarks on Tuesday, Obama spoke with Karzai, who has had a tumultuous relationship with the White House. The two leaders did not see each other while Obama was in Afghanistan, but they did speak by phone as Air Force One was returning to Washington. They spoke again Tuesday morning.

Obama has also discussed his plans with several European leaders, including German Chancellor Angela Merkel, British Prime Minister David Cameron and Italian Prime Minister Matteo Renzi.

The Associated Press contributed to this report.