By Jeff Mason

ATHENS (Reuters) - U.S. President Barack Obama, stung by the surprise victory of Donald Trump in last week's U.S. election, warned on Tuesday against a rise in nationalism and said a backlash against globalization had stoked populist movements at home and abroad.

Obama said distrust of elites and governing institutions had fed success in the U.S. election for Senator Bernie Sanders, who challenged Hillary Clinton in a drawn-out Democratic primary contest, and for Trump, a former reality TV star who bested the former secretary of state in the U.S. presidential race.

"When you see a Donald Trump and a Bernie Sanders, very unconventional candidates, have considerable success, then obviously there is something there that's being tapped into: a suspicion of globalization, a desire to rein in its excesses," Obama said in Greece at the start of a farewell tour of Europe.

Though he rejected a direct comparison between the U.S. election and Britain's "Brexit" referendum in June to leave the European Union, Obama said the common theme of antipathy to globalization was at play, spurring populist movements on the left and right in Europe.

Trump garnered support on the back of promises to build a wall on the U.S. border with Mexico, ban Muslims temporarily from entering the United States and rip up trade deals that he said had hurt American workers.

Obama, who campaigned vigorously for Clinton, opposed those positions and is fighting now to keep his legacy accomplishments on healthcare, climate change, and nuclear diplomacy alive in the face of Trump's promises to dismantle them.

"DANGEROUS" DIVISIONS

Since the election, however, Obama has promised to ensure a smooth and peaceful transition of power, largely backing off his criticism that Trump is unfit to serve as U.S. commander-in-chief. While reiterating that commitment about a transition on Tuesday, Obama seemed to renew his criticism of some of Trump's electoral tactics with a warning about divisions worldwide.

Story continues

"I do believe, separate and apart from any particular election or movement, that we are going to have to guard against a rise in a crude sort of nationalism or ethnic identity or tribalism that is built around an 'us' and a 'them,'" he said.

"I will never apologize for saying that the future of humanity and the future of the world is going to be defined by what we have in common as opposed to those things that separate us," he said.

Unity in Europe in the aftermath of World War Two has created five decades of unprecedented peace and prosperity, he said.

"In the United States, we know what happens when we start dividing ourselves along lines of race or religion or ethnicity. It's dangerous," he said.

(Reporting by Jeff Mason; Editing by Gareth Jones)