Modi spoke Wednesday with Ghani over phone and congratulated him on his election as president of Afghanistan, a statement from the PMO said.
The prime minister lauded Ghani's "wisdom and statesmanship" and his commitment to unity, peace and progress in Afghanistan, which had enabled the formation of a broad-based and inclusive government and a peaceful political transition.
Modi paid tributes to the people and the political leaders of Afghanistan for their faith in democracy and their determination to prevail over violence and terrorism.
Ghani, on his part, conveyed his deep sense of appreciation for Modi's letter of congratulations.
He described India as "the foundation of Afghanistan's diplomacy and economic strategy".
The PMO statement said Ghani accepted Modi's invitation to visit India at the earliest opportunity.
He also suggested immediate commencement of dialogue between the two governments, including between their national security advisors and economic advisors.
Modi expressed confidence that Ghani's "expertise, global experience and grassroot knowledge", borne out of travel to every district of Afghanistan, would help him implement his bold agenda of economic reforms and development in Afghanistan.
Modi also mentioned that Ghani's experience would be beneficial for India and the region, the statement said.
"Prime Minister Modi conveyed that India will stand with him as a friend and a partner, at every step on the way, as his government moves forward in its efforts to build a strong, stable, peaceful, democratic, inclusive and prosperous nation," it said.
Modi noted that India's relations with Afghanistan have been forged by ancient cultural links and timeless bonds of mutual affection and admiration, which had grown deeper in recent years as the Afghan people have strived to rebuild their lives and their nation.
Ghani complimented Modi on his electoral success and his "development vision" which, he said, would be beneficial for Afghanistan and the entire region.