The US President also lauded Manmohan Singh for his efforts to lift millions out of poverty and position India as a global leader.
Obama had also called up Singh last week to say he will miss working with him on a "day-to-day" basis.
"While it was a pleasure to talk to you on the phone, I wanted to respond to your thoughtful letter and put in writing my deep appreciation for your remarkable two terms in office," the Barack Obama said in the letter, which was in response to Singh's farewell letter to him.
Singh resigned on May 17, a day after BJP-led NDA got landslide majority in the Lok Sabha elections. Obama had called him hours later.
"With boldness and vision, during your ten years in office, you challenged our two nations to deepen our defense ties, engage in civil nuclear commerce, expand trade, and collaborate on clean energy technology while working through our differences," Obama wrote to Singh.
"I have tremendous gratitude for the critical role you have played in defining and expanding the strategic partnership between India and the United States," he said.
The US leader told Singh that his leadership helped "strengthen a strategic relationship that will have a long-lasting impact on our citizens and is already making the world a safer, more prosperous place."
Recalling their association, Obama said the two had joined to fight terrorism, prevent the proliferation of weapons of mass destruction, and promote peace in Afghanistan.
"We also embarked on substantive, strategic exchanges that have helped shape our shared views of global developments, allowing us to coordinate and respond more effectively to breaking events," the US President wrote.
He said that even before he became President, he "greatly admired" Singh's dedication to alleviate India's poverty, primarily through economic reforms.
"Your efforts lifted millions out of poverty and positioned India for its transformation into a global leader."
He also commended Singh for his resolve to reach out to Pakistan, "which showed the path to a stable, peaceful South Asia."
Obama said he was "proud that the United States could play a role in your efforts to build a dynamic, prosperous nation, which I believe will bring great benefit to our countries and the world."