Barack Obama during the 2018 Nelson Mandela Annual Lecture at the Wanderers Cricket Stadium in Johannesburg on July 17.

NAIROBI — In his biggest speech since leaving the White House, Barack Obama attacked “strongman politics” and politicians who "just make stuff up," which has been seen as a coded critique of Donald Trump.

While delivering the highly anticipated Nelson Mandela Annual Lecture in Johannesburg, Obama talked about the importance of political compromise, but emphasized that it can only be possible if the parties involved can agree on basic principles.

"This is another one of those things I didn’t think I had to lecture about. You have to believe in facts," he said, earning what appeared to be a knowing laugh from some of the 15,000 people in attendance.

"Without facts, there’s no basis for cooperation," he continued. "If I say this is a podium and you say it’s an elephant, it’s going to be hard for us to cooperate."

Although Obama never referred to Trump by name, people on Twitter were quick to draw references to the current US president, whose campaign and administration have been criticized as being rooted in falsehoods.

Hey @realDonaldTrump , OBAMA is mocking u from a shithole "You have to believe in facts. If I say this is a podium and you say it's an elephant, we cannot find common ground. If you say climate change is a hoax, I don't know where to begin. You cannot just make stuff up." 🤣😊

Obama definitely talking about Trump now....
"You have to believe in facts," he tells the crowd. "Without facts there is no basis for cooperation.
"If I say this is a podium and you say this is an elephant, it is going to be hard for us to cooperate."
#bbc #news #MandelaLecture

Obama takes out Trump directly and the crowd is loving it. Says we must have some facts/ objective truth to agree on, like climate change. “People just make stuff up”. Also goes on about politicians “completely lying” #MandelaLecture. The sun setting isn’t the only shade here 😂

Obama criticizes Trumps stance on climate change. "If I say, this is a podium and you say this is an elephant, we have no common ground to collaborate. You can't say climate change isn't an issue when the entire world thinks."

In his speech, Obama talked about the "strange and uncertain times we’re in," and the "news cycles bringing more head-spinning and disturbing headlines."

He also more directly called out the rise of “strongman politics” one day after Trump and Russian President Vladimir Putin met for a one-on-one meeting in Helsinki, Finland.

"A politics of fear and resentment and retrenchment began to appear and that kind of politics is now on the move," he said, highlighting the related threats to press freedom and condemning the use of social media to spread "hatred and paranoia and propaganda and conspiracy theories."

He acknowledged that "it’s tempting right now to give into cynicism," but once again referenced former South African president Mandela’s philosophy to inspire hope.

Brendan Smialowski / AFP / Getty Images

Russian President Vladimir Putin (right) and US President Donald Trump shake hands before a meeting in Helsinki, on July 16.

"People must learn to hate. And if they can learn to hate, they can be taught to love," Obama said.

Obama’s speech served as the main event intended to commemorate 100 years since Mandela, the anti-apartheid freedom fighter, was born. Obama regularly referenced Mandela’s ideals of fighting against oppression of marginalized people and promoting inclusion.

He spoke about a truth that he said unites all religions: "That we should do unto others as we’d have them do unto us; that we see ourselves in other people; that we can recognize common hopes, common dreams."

That truth, Obama said, "is incompatible with any form of discrimination based on race, or religion, or gender, or sexual orientation," and that when embraced, it empowers nations by allowing them to “draw upon the talents, and energy, and skills of all its people.

"And if you doubt that, just ask the French football team that won the World Cup," he said. "Because not all of those folks look like Gauls to me, but they’re French."

Tamerra Griffin is a reporter for BuzzFeed News and is based Nairobi, Kenya.