KABUL — The United States and Afghanistan are nearing agreement to rewrite key aspects of their plan for ending U.S. military involvement in the war against Taliban and al-Qaida fighters here, U.S. and Afghan officials said Saturday.

In a joint appearance, Afghan President Ashraf Ghani and visiting U.S. Defense Secretary Ashton Carter acknowledged that they are rethinking the pace of the U.S. military withdrawal, the scope and frequency of U.S. counterterrorism raids and whether they should keep U.S. bases open longer than projected. Although they declined to offer more specifics, they indicated that a new deal could be reached as soon as next month, when Ghani is scheduled to visit Washington to meet with President Obama.

Afghan officials and U.S. military commanders have previously acknowledged pressing Obama for more leeway in determining how quickly the remaining 10,600 U.S. troops in Afghanistan are withdrawn over the next two years. But the comments Saturday by Ghani and Carter were the clearest sign yet that changes are afoot.

“President Obama is considering a number of options to reinforce our support for President Ghani’s security strategy, including possible changes to the timeline for our drawdown of U.S. troops,” Carter told reporters. “Our priority now is to make sure this progress sticks.”

The U.S. military ended conventional combat operations in Afghanistan on Dec. 31. American troops remain in the country to train and advise about 350,000 Afghan security forces in their fight against the Taliban.

U.S. troop levels are currently scheduled to dwindle to 5,500 by the end of this year and to drop to zero by the time Obama leaves office in early 2017, save for a small residual force based at the large U.S. Embassy compound in Kabul.

U.S. military commanders, however, have sought more flexibility in drawing down troop levels over that period as well as broader latitude to conduct counterterrorism raids and airstrikes against Taliban and al-Qaida targets.

Ghani said he was “gratified” by a recent Obama directive that temporarily kept an extra 1,100 troops in Afghanistan. But he indicated he would not try to lobby Obama to change his mind about completing the U.S. military pullout by the end of his term, saying he “respected” Obama’s decision.