The IS jihadist group, currently in control of large parts of Syria and Iraq, was confirmed in January by NATO to be recruiting fighters in Afghanistan and neighboring Pakistan.
"Fortunately, we've prevented them from acting. But we have sufficient evidence that they were targeting us because to their narrative, to their story line, Afghanistan is central," Ghani said, as quoted by NBC.
Last week, European Council President Donald Tusk said Tunisia may become the next country targeted by ISIL militants following a deadly attack at the Bardo museum in the capital city of Tunis.
President Ghani is in the United States for his first official visit after assuming office in September 2014. The Afghan leader will meet US President Barack Obama and other senior US officials.
Ghani's visit comes nearly three months after the US-led NATO mission ended combat operations in Afghanistan. Some 7,000 US troops are still deployed in the country providing military training.