Barack Obama warned of the dangers of succumbing to “crude” nationalism on Tuesday, in apparent reference to the election of Donald Trump and Britain’s vote to leave the European Union.

The outgoing President made the remarks in Greece at the start of his last foreign trip as leader of the free world.

"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'," Mr Obama said in Athens, the first stop on a tour that will also take him to Germany and Peru.

"We know what happens when Europeans start dividing themselves up...the 20th century was a bloodbath." He said the US was all too aware of how "dangerous" it was to "(divide) ourselves along lines of race or religion or ethnicity."

The President was asked whether he saw any parallels between Brexit and Mr Trump’s surprise victory. He said it was clear that people’s lives had been disrupted by economic dislocation, globalisation and inequality, and that those concerns needed to be addressed.

"The more aggressively and effectively we deal with those issues, the less those fears may channel themselves into counterproductive approaches that can pit people against each other," he said at a press conference with Alexis Tsipras, the Greek prime minister.