In a BBC interview, Mr Ghani said IS was “not an Afghan phenomenon” and its atrocities had “alienated the people”.
“Afghans are now motivated by revenge,” he said. “They [IS] have confronted the wrong people.”
Mr Ghani also called for anti-IS action at regional and international level.
“There is no denial that we are dealing with very significant risks,” he said, during a visit to the World Economic Forum in the Swiss ski resort of Davos.
“A lot of my diplomacy has been to create the regional consensus, and a region with the inheritance of previous animosities and short-sighted behaviour is something that is going to require effort and focus.”
The US state department said last week that it had designated the IS offshoot in Afghanistan as a terrorist organisation.
It said the group had formed in January last year and was made up of former members of the Pakistani Taliban and Afghan Taliban.
In other comments, Mr Ghani warned that if peace talks with the Taliban did not start by April the conflict would intensify, with consequences across the region.
“Time is not a friend,” he said. “We all understand that February and March are crucial.”
The Afghan president said observers should understand that the war in his country was “just one component” of a wider war that also encompassed Pakistan.
“The problems… are interrelated [and] cannot be solved by use of force in one country.
He suggested Pakistan should take action against Taliban groups that did not agree to talks.
“We need to see that we have common interests and we need to act together to preserve the state system and consolidate it,” he said.
Asked what message he had for Afghan migrants arriving in Europe, Mr Ghani said: “What I say to them is that you have no future in Europe. Europe is shutting down its borders.
“You’ve just had an interview with the French prime minister – broadcast that to them. The future is Afghanistan.”