His comments are seen as thinly veiled criticism of the current US administration's use of what has been described as "alternative facts".
Here are five key points from his Nelson Mandela lecture, made to the world's media and an audience of some 15,000 people in South Africa's main city, Johannesburg.
1. Facts are sacred
"You have to believe in facts," said Mr Obama, "without facts there is no basis for co-operation.
"If I say this is a podium and you say this is an elephant, it is going to be hard for us to co-operate."
Mr Obama said that he could find common ground with people who disagreed with the Paris accord on climate change - which Donald Trump wants to pull the US out of - if they had an argument based on fact.
But, Mr Obama added: "I can't find common ground if someone says climate change is not happening when almost all the world's scientists say it is. If you start saying it is an elaborate hoax, where do we start?"
Mr Trump has said he thinks climate change is not happening.
A moment later, Mr Obama told the audience: "It used to be if you caught them [politicians] lying, they said: 'Oh man'. Now they just keep on lying."
2. Immigration is a strength
Barack Obama said striving towards equality ensures a society can draw on the talents and the energy of all of its people.
"Just look at the French football team," he said to wild cheers, referring to France's World Cup win days before.
"Not all of those folks looked like Gauls to me, but they are French - they are French."
It is a "plain fact" that racial discrimination still exists in the US and South Africa, Mr Obama said.
3. Business titans are 'isolated from ordinary people'
Barack Obama said the world's elite were out of touch with the lives of the poor.
"In their business dealings, many titans of industry... are increasingly detached from any nation state" and they "live lives more and more isolated from ordinary people", he said.
As a result, their decisions to "shut down a factory" were seen as simply a "rational response" to shareholders' demands.
4. Viva democracy!
Politicians using "politics of fear, resentment, retrenchment" were rising "at a pace unimaginable just a few years ago," Barack Obama warned.
Democracy is messy, he said, "but the efficiency of an autocrat is a false promise".
"It is time for us to stop paying all of our attention to the world's capitals... and focus on the world's grassroots. That is where democracy comes from," he added.
Warning against creeping populism and "strongman politics", he made the case for liberal democracy, saying that he believed it offered the better future for humanity.
"I believe in Nelson Mandela's vision" for the world's future, he said, "I believe that a world governed by such principals is possible".
"It can achieve more peace and more cooperation in pursuit of a common good," he added.
"I believe we have no choice but to move forward... I believe it is based on hard evidence. The fact that the world's most prosperous and successful societies happen to be those which have most closely approximated the liberal progressive ideal that we talk about."
Things may go backwards for a while, but - ultimately - right makes might," Mr Obama said. "Not the other way around."
5. Keep hope alive
"Keep believing. Keep marching. Keep building. Keep raising your voice. Every generation has the opportunity to remake the world," Mr Obama said, ending his speech on a positive note.
To loud cheers, he called on young people listening to him to get "fired up".
"We don't just need one leader... what we badly need is that collective spirit," he added.
"Mandela said young people are capable when aroused of bringing down the towers of oppression and raising the banners of freedom," he said. "Now is a good time to be aroused."
- Countries: United_States
- Jump-Start Private Investment to reignite South Africa's Growth says IMF
- New Film Reveals Plot to Infect Black South Africans with HIV
- G20 Summit: BRICS Pushes For 'Democratic International Order'
- Michelle Obama’s Becoming is an insight into inequality, feminism and a FLOTUS who broke the mould
- Marrying technology and home language boosts maths and science learning