NEW DELHI -- President Obama has long shown a fascination with Mohandas Gandhi, hanging a photo of the slain Indian independence leader on the wall of his office and citing Gandhi in his Nobel Prize acceptance speech.

On Sunday, Obama visited Raj Ghat, the site that holds Gandhi’s ashes, slowly walking around the memorial and scattering rose petals on it.

Obama is in India for a trip that is rich in symbolism as the United States and India look to strengthen a relationship that has been cool for years and as he and Indian Prime Minister Narendra Modi seek to cement a friendship they hope will benefit both countries. And the leaders are turning to Gandhi for inspiration.

President Obama traveled to New Delhi, India in January 2015, ahead of the country’s Republic Day celebrations. (Reuters)

That bond was forged in Washington in September, when both men visited the Martin Luther King Jr. Memorial in Washington. Obama decided at the last minute to join Modi at the memorial, and the spirit of Gandhi permeated the visit.

Many here in India are proud that King was inspired by Gandhi’s nonviolent protests, traveling to India in 1959, and Obama has evoked both men in the past.

“As someone who stands here as a direct consequence of Dr. King's life work, I am living testimony to the moral force of nonviolence.  I know there's nothing weak -- nothing passive -- nothing naïve -- in the creed and lives of Gandhi and King,” Obama said during his Nobel speech in 2009.

Obama alluded to King again Sunday, writing about him in the guestbook.

“What Martin Luther King, Jr., said then remains true today. The spirit of Gandhi is very much alive in India today,” he wrote. “And it remains a great gift to the world. May we always live in his spirit of love and peace among all people and nations.”

Other White House officials noted the link.

When Modi visited Obama in September, he brought the president several items of King memorabilia from the 1959 trip, including a framed photograph of King laying a wreath at Gandhi’s tomb and an audiotape of a speech King gave to All India radio.

Modi has also held up Gandhi, citing him along with Obama in an op-ed the two wrote in September. Obama’s visit comes days before the anniversary of Gandhi’s death on Jan. 30. Modi did not accompany Obama to the memorial.

Obama has paid tribute to Gandhi in India before, visiting the memorial and Gandhi’s former home in Mumbai. Obama wrote in a guestbook that Gandhi was a hero not only to India, but to the world. And he has evoked Gandhi and King with other Indian leaders.

"There was a discussion between the President and the previous Prime Minister, Prime Minister Modi’s predecessor, about the relationship -- or at least the intellectual relationship between Gandhi and Martin Luther King," White House press secretary Josh Earnest said in September, "and that they pursued in trying to bring a chance in their countries a similar commitment to nonviolence that I think Prime Minister Modi and certainly President Obama greatly admires."

When he was asked by students in 2009 which person, dead or alive, he would like to have dinner with, Obama said Gandhi.

“He’s somebody I find a lot of inspiration in,” he said. “"He ended up doing so much and changed the world just by the power of his ethics."

After scattering flowers on the memorial, Obama was supposed to plant a tree, but it was already in the ground. He spread dirt around the sapling and watered it with a pitcher.

“Big and strong,” he said to the plant.