Barack Obama has said the world is living through “strange and uncertain” times, as he decried the type of “strongman politics” practised by Donald Trump in his most high-profile speech since leaving the White House.

Mr Obama urged people around the world to respect human rights and other values now under threat, in an impassioned address as he marked Nelson Mandela’s life on the 100th anniversary of his birth.

The US’s first black president was greeted by a stadium full of people in Johannesburg, South Africa, with chants of “Yes, we can” – his well-known campaign slogan from 2008.

“Each day’s news cycle is bringing more headspinning and disturbing headlines,” Mr Obama said, in an apparent reference to Mr Trump who he did not mention by name during the speech. These days “we see much of the world threatening to return to a more dangerous, more brutal way of doing business”, he added.

He attacked “strongman politics”, saying that “those in power seek to undermine every institution ... that gives democracy meaning”.

Mr Obama hit out at the current increase in attacks on free press, adding that there is an “utter loss of shame among political leaders when they’re caught in a lie”. It is not much of a stretch to suggest that Mr Obama was again thinking of his successor Mr Trump – who has repeatedly admonished “fake news”, even when they are pointing out false statements he has made.

He noted that though the world had progressed leaps and bounds – in terms of ending apartheid, the fall of dictatorships, and technology connecting people – there is a “politics of fear, resentment, retrenchment... now on the move ...[at a] pace that seemed unimaginable even a few years ago”.

Barack Obama's best moments in the White House Show all 11 1 /11 Barack Obama's best moments in the White House Barack Obama's best moments in the White House May 19, 2009 “The President was leaving the State Floor after an event and found Sasha in the elevator ready to head upstairs to the private residence. He decided to ride upstairs with her before returning to the Oval Office,” Peter Souza Barack Obama's best moments in the White House Oct. 26, 2012 President Barack Obama pretends to be caught in Spider-Man's web as he greets the son of a White House staffer in the Outer Oval Office Peter Souza Barack Obama's best moments in the White House “A National Security staffer, Carlton Philadelphia, brought his family to the Oval Office for a farewell photo with President Obama. Carlton’s son, Jacob, softly told the President he had just gotten a haircut like President Obama, and asked if he could feel the President’s head to see if it felt the same as his.” Peter Souza Barack Obama's best moments in the White House March 21, 2010 The President, Vice President and senior staff applaud after watching on television the House vote on H.R. 4872 for health care reform, in the Roosevelt Room of the White House Peter Souza Barack Obama's best moments in the White House Dec. 3, 2009 President Barack Obama fist-bumps custodian Lawrence Lipscomb in the Eisenhower Executive Office Building following the opening session of the White House Forum on Jobs and Economic Growth Peter Souza Barack Obama's best moments in the White House Sept. 22, 2015 "The Obama family and Biden family greet Pope Francis as he arrives in the United States for the first time at Joint Base Andrews," Sept. 22, 2015. Peter Souza Barack Obama's best moments in the White House Feb. 21, 2014 President Barack Obama and Vice President Joe Biden participate in a "Let's Move!" video taping on the Colonnade of the White House, Feb. 21, 2014 Peter Souza Barack Obama's best moments in the White House Feb. 18, 2016 President Barack Obama watches First Lady Michelle Obama dance with 106-Year-Old Virginia McLaurin in the Blue Room of the White House prior to a reception celebrating African American History Month, Feb. 18, 2016 Peter Souza Barack Obama's best moments in the White House Jan. 21, 2013 "The President and First Lady wave to supporters as they ride in the inaugural parade. I had asked the President if I could ride in the presidential limousine and the President joked, 'But Michelle and I were planning to make out," Jan. 21, 2013. Peter Souza Barack Obama's best moments in the White House Barack Obama and former First Lady Michelle Obama share a private moment in a freight elevator at an Inaugural Ball, January 2009 all pics: Pete Souza Barack Obama's best moments in the White House Barack Obama rests his hand on the bible that President Lincoln used for his swear-in, being held by his wife Michelle Obama as he is sworn in as the 44th President of the United States of America Rex

Mr Obama appeared relaxed, joking with new South African president Cyril Ramaphosa who had taken the podium earlier to a standing ovation and singing from the crowd in support of his recent electoral victory.

The US leader said Mr Ramaphosa “brings new hope to this great nation”, but the crux of his lecture was to focus “on where we’ve been and how we arrived, in the hopes that it offers a roadmap on where we need to go next” in passing the torch of Mr Mandela’s ideals.

“Madiba,” as he was affectionately referred to by all the day’s speakers, was released from his decades in prison just “a few months after the fall of the Berlin Wall”, Mr Obama reminded the crowd.

Trump lashes out as Obama-era photos of immigrant children in steel cages linked to current administration

“On Madiba’s 100th birthday we stand at a crossroads... a moment in time in which two very different visions” can take hold, Mr Obama said.

Those who believe in reducing income inequality, fight climate change, believe in education for all “have a better story to tell”, Mr Obama said.

However, he warned: “To say our vision of future is better is not to say that it will inevitably win.”

He explained how the wealthy have an outsized influence on politics, particularly in “populist movements... cynically funded by right-wing billionaires”, in what may have been a jab at Mr Trump and major Republican donors like the Koch brothers.

He said “those in power seek to undermine every institution ... that gives democracy meaning” and attacked “strongman politics”.

“I am not being alarmist, I am simply stating the facts. Look around,” the former US leader added.

He dipped momentarily into a rhetoric of idealism and a fierce defence of tolerance.

In a sobering moment, Mr Obama noted “the struggle for basic justice is never truly finished”.

“History shows the power of fear. History shows how easily people can be convinced to turn on those who look different... We’re going to have learn from the mistakes of the recent past,” Mr Obama said. He also pointed to a world history of xenophobic nations being “consumed by civil war”.