WASHINGTON (AP) -- President Barack Obama agreed Tuesday to slow the U.S. military pullout from Afghanistan at the request of its new government but insisted the delay won't jeopardize his commitment to end America's longest war before leaving office.

In a shift from his previous plan, Obama said the U.S. would leave its 9,800 troops currently in Afghanistan in place rather than downsizing to 5,500 by year's end. The size of the U.S. footprint for next year is still to be decided, he said, but he brushed aside any speculation the withdrawal will bleed into 2017 when the next president takes over.

"The date for us to have completed our drawdown will not change," Obama declared.

Afghan President Ashraf Ghani's inaugural visit to the White House offered a stark contrast to visits by his predecessor, Hamid Karzai, who was viewed by U.S. officials as prickly and unreliable. Ghani went out of his way to thank the U.S. for its sacrifices in his country, offering a window into the efforts by Obama and him to rehabilitate the U.S.-Afghan relationship.

"This visit is an opportunity to begin a new chapter between our two nations," Obama said during a joint news conference in the East Room.

As for the delayed drawdown of U.S. troops, Obama said he and his military leaders believe "that providing this additional time frame during this fighting season for us to be able to help the Afghan security forces succeed is well worth it."

He acknowledged the change of plans will prevent some U.S. troops from coming home when they expected, but he suggested the danger will be minimized because they won't be in combat. The U.S. combat role in Afghanistan officially ended late last year, a down payment on Obama's re-election pledge to wind down the war the U.S. launched in the days after the Sept. 11, 2001, attacks.

The policy shift followed weeks of White House deliberations about whether to fulfill Ghani's requests to keep more troops in Afghanistan longer - particularly as the tough spring fighting season approaches. Afghan security forces are still struggling to gain the strength needed to protect the volatile country and to fend off Islamic State fighters whose attempts to recruit in Afghanistan have been cause for regional concern.

"Afghanistan remains a very dangerous place," Obama said, noting that insurgents still launch attacks and plot suicide bombings to target civilians. Yet he declared his confidence in Ghani, who he said had "taken on the mantle of commander in chief in a way that we have not seen in the past from an Afghan president."

Obama's foreign policy critics, including some hawkish Republicans, have long urged him to leave more forces in the country and have accused him of setting artificial, politically driven deadlines for withdrawal. House Speaker John Boehner of Ohio said he was reviewing Obama's proposal and hoped it would "meet the requests of our Afghan partners, our commanders on the ground and bipartisan members of Congress."

For Obama, Ghani represents a last, best hope to make good on a key component of his foreign policy legacy: his promise to end the war before leaving office, keeping a thousand or so troops at the embassy to coordinate security.