Former US President Barack Obama delivers the 16th Nelson Mandela annual lecture, marking the centenary of the anti-apartheid leader's birth, in Johannesburg. Picture: Siphiwe Sibeko/Reuters

Johannesburg - Barack Obama, the first black president of the United States, paid homage on Tuesday to the late Nelson Mandela, South Africa's first black leader, on the centenary of his birth.

Obama lauded Mandela - who spent 27 years in prison for his struggle against South Africa's racist apartheid government - but his speech was also heavily focused on the global political present.

"It is a singular honour for me to be here... gathered to celebrate the birth and life of one of history's true giants," Obama said on taking the podium.

Mandela "came to embody the universal aspirations of dispossessed people all around the world with hopes for a better life, and the possibility of a moral transformation in the conduct of human affairs," Obama said.

Obama described how the world seemed to be becoming steadily more progressive at the turn of the century, but that the international order had fallen short of some of its promises and the result had been the rise of "reactionary" politics.

"On Madiba's 100th birthday, we now stand at a crossroads. A moment in time in which two very different visions of humanity's future competes about who we are and who we should be," the former US leader said.

In what appeared to be a thinly veiled reference to his successor Donald Trump, Obama on Tuesday said the world was going through "strange and uncertain times."

"Each day's news cycle is bringing more head-spinning and disturbing headlines," the former US leader said.

"More than a quarter-century after Madiba walked out of prison, I still have to stand here saying people of all races and women and men are the same," Obama said to huge applause.

South African President Cyril Ramaphosa, who replaced Jacob Zuma as president this year after the latter was forced to step down, gave an equally political address before introducing Mandela.

"As our nation is filled with renewed hope ... I keep hearing Madiba's voice right into my ear, saying 'I am sending you to serve the nation.'"

"Madiba is sending all of us to deal with corruption and root it out," Ramaphosa added.

Zuma has been accused of allowing 'capture of the state' by granting lucrative government tenders to personal friends. He is currently on trial on charges of fraud, racketeering and corruption.

The Zuma scandals badly tarnished Mandela's African National Congress. Ramaphosa, however, was a favourite of Mandela's and has brought hope to South Africans tired of the rampant corruption in the country.

Thousands of people attended the event, titled, "Renewing the Mandela Legacy and Promoting Active Citizenship in a Changing World" and held at a cricket stadium in Johannesburg.

South Africans of all ages and races who entered the stadium on the cold winter morning ahead of the speech told dpa about their reasons for celebrating Mandela's centenary.

"He's one of the greatest South Africans because he took us through a very turbulent time, and when he came out of jail he was totally forgiving," said Clive Acton, 78. "I want to be here to feel his presence."

Acton, a retired management consultant, said he thought Obama was the perfect keynote speaker because "in many ways, he reminds me of Mandela."

Orentse Miya, a 22-year-old university student and member of the so-called "born-free" generation born after the end of apartheid, said that it was up to the youth to continue carrying out Mandela's work.

"I wanted to be here to celebrate Nelson Mandela since he has pioneered us into democracy," Miya told dpa.

In true Madiba spirit, one of Mandela's former prison guards from Robben Island - who later become friends with liberation hero - attended the event, local media reported.

A woman attending Tuesday's speech said that while she was there celebrate Mandela, his legacy has not always persisted in present-day South Africa.

"We have to be grateful, but we have to be honest - a lot of his legacy hasn't been lived by many young South Africans," university lecturer Ayanda, 36, told dpa.

But Graca Machel, Mandela's widow, said in her remarks at the event that her husband "said on many occasions that he was not a saint."

"Madiba and his contemporaries laid a solid base for today's generation," she said. "The youth of this country must follow in his footsteps, as the promises of social and economic justice are theirs to fulfil."