Despite the "strange and uncertain" times President Barack Obama says we're living in he still believes in "a vision of equality and justice and freedom" he said in a speech on Tuesday to commemorate the late Nelson Mandela – Obama's first visit to Africa since leaving office.

"I believe in a vision of equality and justice and freedom and multiracial democracy built on the premise that all people are created equal," Obama said. "They are endowed by our creator with certain inalienable rights. I believe that a world governed by such principle is possible and it can achieve more peace and more cooperation in pursuit of a common good. That’s what I believe. I believe we have no choice but to move forward. Madiba shows that those of use who believe in freedom in democracy, we’re going to have to fight harder to reduce inequality and promote lasting economic opportunity for all people.”

The speech falls on the day before Mandela’s 100th birthday and is part of the series of events the Nelson Mandela Foundation has planned for the milestone. Before the lecture, Mandela's wife, Graça Machel, told the crowd of more than 15,000 people that Obama is one of the "finest global leaders of the 21st century" and a "youthful symbol of transformative leadership."

Mandela is known for being "the epitome of civil action" after he was imprisoned for 27 years for attempting to end apartheid in Africa, a system of institutionalized segregation that existed in South Africa for years. The global icon died in 2013 and his legacy as the first black president of South Africa and years of activism will be celebrated with the 16th Nelson Mandela Annual Lecture.

This year’s theme is titled "Renewing the Mandela Legacy & Promoting Active Citizenship in a Changing World." Obama is the second U.S. president to deliver the lecture. Bill Clinton spoke in 2013.

Obama sought to echo Mandela's message in a speech that touched on the need to work together despite differences. He said he shares the vision of such such leaders as Mandela, Martin Luther King Jr. and Abraham Lincoln.

"Given the strange and uncertain times that we are in – and they are strange – and they are uncertain – with each day's news cycles bringing more head-spinning and disturbing headlines, I thought maybe it would be useful to step back for a moment and try to get some perspective," Obama said.

Obama stressed the importance of having an open-mind and teaching children critical thinking rather than "blind obedience." He added that the youth will be able to create change by continuing to persist.

“Keep believing,” Obama said. “Keep marching. Keep building, Keep raising your voice. Every generation has the opportunity to remake the world. Mandela said ‘Young people are capable when aroused of bringing down the towers of oppression and raising the banners of freedom’ Now is a good time to be aroused. Now is a good time to be fired up.”

Obama also warned the crowd of "strongman politics."

"Strongman politics are ascendant, suddenly, whereby elections and some pretense of democracy are maintained, the form of it, but those in power seek to undermine every institution or norm that gives democracy meaning," he said.

Obama closed his speech with a quote from Mandela: "No one is born hating another person because of the color of his skin, or his background, or his religion. People must learn to hate, and if they can learn to hate, they can be taught to love, for love comes more naturally to the human heart than its opposite."

Obama tweeted the same quote in response to the violence in Charlottesville, Virginia, the tweet became Twitter's the second most retweeted tweet of 2017.

For those in the crowd, Obama's soaring oratory was inspiring.

“Obama is one of the greatest orators of our time. He inspired me to be the change,” said Maria Morapedi.

Before Obama delivered his speech on Tuesday, the former president made a stop in Kenya on Monday to assist in the grand opening of a sports and fitness center. Founded by Obama's half-sister Auma Obama, the facility is in the city of Kogelo, the birthplace of their father.

Since parting office in 2017, Obama has spent his time delivering speeches, meeting with potential 2020 presidential candidates and spending a substantial amount of time on his foundation based in Chicago. Obama’s speech in Johannesburg is considered one of the most high-profile appearances the president will attend since his presidency.

ABC News' Liezl Thom contributed to this report from Johannesburg.