Speaking to a gathering of American soldiers and top officials at the Pentagon, Ghani repeatedly expressed appreciation for the sacrifices of the more than 850,000 troops who have been deployed in Afghanistan since the attacks of September 11, 2001.
The Afghan president said he came "to say thank you on behalf of a grateful nation to people in this building and the larger US community for sacrificing continuously since September 11 to bring us freedom and hope."
After thanking American troops and diplomats, Ghani pledged that "we are not going to be a burden."
"We do not now ask what the United States can do for us," he said, turning around a famous phrase by former president John F Kennedy.
More From This Section
"We want to say what Afghanistan will do for itself and for the world. And that means we are going to put our house in order."
Ghani's approach including his vow to fight corruption has been warmly welcomed by President Barack Obama's administration, which grew frustrated with Karzai's tirades.
Ghani's four-day visit is being given a high priority by the White House, which is eager to show the Afghan leader that Washington is ready to remain a dedicated partner even as the US military presence declines.
Later today, Ghani will take a large delegation to the US presidential retreat at Camp David.
At the close of the event, Ghani walked over to a line of troops to shake their hands, including the widow of US Major General Harold Greene, who was killed by a rogue Afghan soldier last year in Kabul.