Updated at 11:35 a.m. ET.Former president Barack Obama celebrated Nelson Mandela's life and legacy in South Africa on Tuesday with a speech that focused not only on the freedom Mandela came to symbolize but the long walk it took to get there."We have to follow Madiba's example of persistence and hope," Obama said, using Mandela's clan name. "It's tempting right now to give in to cynicism. To believe that recent shifts in global politics are too powerful to push back. That the pendulum has swung permanently. Just as people spoke about the triumph of democracy in the '90s, now you're hearing people talk about the end of democracy and the triumph of tribalism and the strong man. We have to resist that cynicism, because we've been through darker times."It was one of Obama's most high-profile appearances since leaving the White House 18 months ago and a preview of what could be an active campaign schedule for the former president before the midterm elections this fall.Obama spoke to a crowd of about 15,000 in a Johannesburg cricket stadium on the eve of what would have been Mandela's 100th birthday. He remarked on the progress that swept the globe during Mandela's lifetime — with greater prosperity and opportunity — but also that backlash that followed in recent years, in the wake of inequality and insecurity."A politics of fear and resentment and retrenchment began to appear and that kind of politics is now on the move," Obama said. "It is in part because of the failures of governments and powerful elites to squarely address the shortcomings and contradictions of this international order that we now see much of the world threatening to return to an older, a more dangerous, a more brutal way of doing business."Obama argued that progressives need to push back against those trends by emphasizing more inclusive opportunity and international cooperation."We have a better story to tell," he said. "But to say that our vision for the future is better is not to say that it will inevitably win. Because history also shows the power of fear."Obama has generally kept a low profile since leaving office and has avoided criticizing his successor directly. But on rare occasions, the former president has spoken up in defense of inclusive democratic values.Last year, Obama told a large crowd near the Brandenburg Gate in Germany that in a modern, interconnected world, "we can't isolate ourselves. We can't hide behind a wall."It was an implicit rebuke of President Trump's "America First" policies, delivered at a moment when Trump was scolding NATO allies for what he saw as inadequate defense spending — something Trump did again last week.Obama also defended the global economic order, saying it had delivered unparalleled peace and prosperity. But he acknowledged that order was under attack."It has to be continually renewed, because there is a competing narrative of fear and xenophobia and nationalism and intolerance," Obama said. "We have to push back against those trends."Last week, Trump told reporters in the U.K. that immigration is changing the culture of Europe in a negative way."I know it's politically not necessarily correct to say that, but I'll say it and I'll say it loud," Trump said.Obama's critiques of Trump and his party are likely to grow more frequent this fall, when the former president is expected to campaign actively for Democratic House and Senate candidates.But Obama is also looking beyond the United States and the next election.When he traveled as president, Obama often made it a point to meet with young people who might form the next generation of leaders, and he'll do so again this week in South Africa. He's hosting a town hall in Johannesburg on Wednesday for 200 rising African leaders. Copyright 2018 NPR. To see more, visit http://www.npr.org/.