Former US President Barack Obama, who has often talked about the influence of Mahatma Gandhi on his life, on Tuesday invoked him during a major speech, while articulating his vision of equality, justice and freedom.

Johannesburg: Former US President Barack Obama, who has often talked about the influence of Mahatma Gandhi on his life, on Tuesday invoked him during a major speech, while articulating his vision of equality, justice and freedom.

Obama, who scripted history by becoming the first black President of the US in 2009, has long shown a fascination with Gandhi, hanging a photo of the Indian icon on the wall of his Senate office and citing Gandhi in his Nobel Prize acceptance speech.

In an address in honour of anti-apartheid leader Nelson Mandela ahead of the 100th anniversary of his birth, Obama made a plea to his audience to preserve democratic freedoms as the key to peace.

"Let me tell you what I believe. I believe in Nelson Mandela's vision, I believe in a vision shared by (Mahatma) Gandhi and (Martin Luther) King, and Abraham Lincoln, I believe in a vision of equality and justice and freedom and multi-racial democracy built on a premise that all people are created equal and are endowed by our creator with certain inalienable rights.

"And I believe that a world governed by such principles is possible and that it can achieve more peace and more cooperation in pursuits of a common good. That's what I believe," Obama said.

He said that there was a choice between two visions of humanity's future that the world must choose between.

"How should we respond? Should we see that wave of hope that we felt with Madiba's release from prison? From the Berlin Wall coming down? Should we see that hope that we had, as naive and misguided?" he asked.

Obama's speech, the 16th annual Nelson Mandela Lecture, in one of his high-profile appearances and his first return to Africa since he left office in 2017, CNN reported.

His lecture, titled "Renewing the Mandela legacy and promoting active citizenship in a changing world," tracked the transformation of the world, particularly in terms of race relations and human rights, over the past 100 years.

"It is a plain fact that racial discrimination still exists in both the United States and South Africa," he said.