While visiting the Robben Island prison in South Africa where his hero Nelson Mandela spent two thirds of his 27 years in jail, Obama told Sasha and Malia how Gandhi started his non-violent political struggle in South Africa.
"One thing you guys might not be aware of is that the idea of political non-violence first took root here in South Africa because Mahatma Gandhi was a lawyer here in South Africa," Obama said, according to a White House pool report.
"Here is where he did his first political (activism). When he went back to India, the principles ultimately led to Indian independence, and what Gandhi did inspired Martin Luther King," said Obama, the first black president of the US.
In a blue windbreaker and slacks, the US president, along with his wife Michelle and daughters, visited the cell where the anti-apartheid leader was jailed.
Obama, in his speeches, has often said Gandhi has inspired Americans and African Americans, including Martin Luther King.
During a school interaction in the US, Obama had said once that if it were possible, he would have loved to have dinner with Mahatma Gandhi.