This May 25, 2014, file photo shows President Barack Obama speaking during a troop rally after arriving at Bagram Air Field for an unannounced visit, north of Kabul, Afghanistan. Senior U.S. administration officials say President Barack Obama will seek to keep 9,800 U.S. troops in Afghanistan after the war formally ends later this year. Nearly all of those forces are to be out by the end of 2016, as Obama finishes his second term.

WASHINGTON — President Barack Obama will seek to keep 9,800 U.S. troops in Afghanistan after the war formally ends later this year and then will withdraw most of those forces by 2016, senior administration officials said Tuesday.

Obama’s decision is largely in line with what military commanders have been seeking and will allow the president to fully end the American-led military effort by the time he leaves office.

The two-year plan is contingent on the Afghan government signing a bilateral security agreement with the U.S.

Obama was to announce the plan at the White House on Tuesday afternoon.