"There's much work that lies ahead of us, and the flexibility that has been provided will be used to maximum effect to accelerate reforms, to ensure that our security forces honor human rights," Ghani said.
Ghani had asked Obama to slow the withdrawal of U.S. troops from his country because Afghan security forces are bracing for a tough spring fighting season and are also contending with Islamic State fighters looking to recruit on their soil.
The president said that responsibility for Afghanistan's security falls squarely with the country's government.
"Afghanistan is still a dangerous place, and the way it's going to become less dangerous is by Afghan security forces and Afghan police being capable of keeping law and order and security in the country," Obama said. "And that is not going to happen if foreign forces are continually relied upon for the basic security of Afghanistan."
Obama emphasized that helping Afghanistan means more than maintaining a military presence, and the U.S. would work with Kabul to support both security training and nation building efforts.
Read MoreAfghan opium at all time high, despite $7.6B spent fighting it
In his address to the media, Ghani said he "would like to thank the American taxpayer for his and her hard earned dollars that have enabled us."
Ghani represents Obama's last, best hope to make good on his promise to end America's longest war before leaving office.
Ghani came to Washington aiming to prove he's a reliable partner worthy of U.S. support, despite his fractured government and rampant problems in Afghanistan's military.
Some lawmakers had also called for a slower drawdown of troop levels. U.S. Representative Mac Thornberry, a Republican who leads the House of Representatives Armed Services Committee, said the decision announced on Tuesday was "appropriate."
"Iraq has shown us the consequences of leaving a fragile ally too early," he said in a statement. "The bottom line is that our own security is at stake."
—The Associated Press and Reuters contributed to this report.