This article is more than
8 year oldSpeaking in Greece on his final foreign trip, he said: "We have to guard against... tribalism built around an 'us' or a 'them'."
He said the US was painfully aware of the danger of divisions "along lines of race or religion or ethnicity".
He also put the victory of Donald Trump down to "the view of the American people to just shake things up".
Mr Obama was speaking after talks with Greek PM Alexis Tsipras in the capital, Athens, as part of a final tour that also takes in Germany and Peru.
He said again that he had been surprised by Mr Trump's victory.
Mr Obama said part of the result was down to "natural desires for change if you've had an incumbent who's been there for eight years".
"At times of significant stress, people are going to be looking for something and they may opt for change even if they are not entirely confident what that change will bring."
He added: "The lesson I draw is that we have to deal with issues like inequality, economic dislocation, people's fears that their children will not do as well as they have."
Mr Obama said the UK's vote to leave the EU and the US vote showed that people generally were now "less certain of their national identities and place in the world" and that had produced populist movements both on the left and the right.
He said a suspicion of globalisation and elites, wrapped up in issues of religious or ethnic or cultural identity was "a volatile mix".
He said: "Now we need to satisfy the people who are fearful, angry or concerned and that's going to be a pretty big test."
Mr Obama insisted his vision - where "the future will be decided by what we have in common, rather than what leads us into conflict" - was the right one.
He also said he was responsible for facilitating a good transition, presenting to Mr Trump his best ideas about how to move the country forward.
Mr Obama will be using the European leg of his trip to try to reassure leaders about future US commitment to its international alliances.
President Obama comes to Athens partly to talk about democracy in the place in which it was born. There's a lot for him to consider.
In Ancient Greece, not far from the Acropolis, populist speakers used to rouse crowds with the promise of action against the state's enemies. Those speakers were known as demagogues. You have to wonder whether or not that will remind the president of the man who will succeed him.
Modern Greece may also have some interesting lessons for the outgoing president. The recent global wave of populism had its beginnings in this country when the left-wing Syriza movement came to power in January 2015.
The party's leader, Alexis Tsipras, promised to tear down a corrupt system. But almost two years on, Mr Tsipras finds himself carrying out many of the policies he had campaigned against.
Before leaving the US, Mr Obama said President-elect Trump had "expressed a great interest" in maintaining the US commitment to Nato, although during the campaign the Republican had said he might abandon a guarantee of protection for fellow Nato countries.
Article 5 of the Nato treaty commits allies to come to the aid of a member state under attack. Mr Trump's statements had alarmed the Baltic states, which fear Russian aggression.
Much of Mr Obama's news conference with Mr Tsipras concerned the Greek economy.
Greece's debt jargon explained
Mr Tsipras praised Mr Obama for his support and for pursuing an economic policy in the US that focused on quantitative easing and job creation, rather than on the austerity measures favoured in Europe.
Greece agreed a third economic bailout package with international creditors in the middle of last year.
It was worth about €86bn ($92bn) but came with strict austerity measures. Greece says it needs a major debt restructuring programme to ease its economic malaise.
Mr Obama again signalled support for that, saying the Greek economy needed "space to return to growth" and that austerity could not be the only strategy.
Greek anarchist and left-wing groups are now holding protests "against the representative of imperialist powers".
Video footage showed a number of protesters on one street pushing up against police in riot gear, before they were forced back.
Police have banned public gatherings in central Athens and near the city's international airport until after Mr Obama's departure.
Newer articles
<p>The two leaders have discussed the Ukraine conflict, with the German chancellor calling on Moscow to hold peace talks with Kiev</p>