Berlin (AFP) - US President Barack Obama arrived in Berlin Wednesday for talks with German Chancellor Angela Merkel on a European tour aimed at reassuring key allies about transatlantic ties under his successor Donald Trump.

On the final leg of a European farewell tour, Obama touched down in the German capital from Athens where he delivered a sweeping speech warning of the dangers to modern democracy.

The US leader acknowledged that globalisation had fuelled a "sense of injustice" and needed a "course correction" to address growing inequality.

"The global path of globalisation demands a course correction," Obama, 55, said in Athens.

"When we see people, global elites, wealthy corporations seemingly living by a different set of rules, avoiding taxes, manipulating loopholes... this feeds a profound sense of injustice," he added.

However, his remarks also contained a ringing defence of democracy, open markets and social inclusiveness.

"I firmly believe that the best hope for human progress remains open markets, combined with democracy and human rights," the outgoing president said.

Trump welcomed Britain's shock vote in June to leave the European Union (EU) and has been a critic of global free trade agreements.

But Obama argued that "when people have opportunity and they feel confidence in the future, they are less likely to turn on each other and less likely to appeal to some of the darker forces that exist in all our societies, those that can tear us apart".

European governments, especially eastern countries close to Russia's orbit, have been shaken after Trump appeared to call into question Washington's near 70-year security guarantee by saying he would only help NATO allies if they paid their way.

In comments Tuesday, Obama cautioned the world must guard against "a rise in a crude sort of nationalism or ethnic identity or tribalism that is built around an 'us' and a 'them'".

- 'My closest partner' -

Obama has been at pains to stress that Europe -- and NATO -- would remain the cornerstone of US foreign policy.

Story continues

"Today more than ever, the world needs a Europe that is strong and prosperous and democratic," he said.

The US-led NATO grouping is "absolutely vital" to US interests and a strong, unified Europe was good for America and the world, the president said in comments aimed at calming old partners' fears.

"We know what happens when Europeans start dividing themselves up... the 20th century was a bloodbath," he said pointedly on Tuesday.

Obama has described Merkel as "probably... my closest international partner these last eight years."

During his time in Berlin, he will also meet the leaders of Britain, France, Spain and Italy, as Europe desperately seeks clues to future US policy in a Trump world.

While Obama was generally been welcomed in Greece, his visit was also met with street protests.

For more news videos visit Yahoo View, available now on iOS.

Around 2,500 people brandishing banners denouncing US "imperialism" and calling Obama a "persona non grata" were pushed back on Tuesday as they tried to breach barriers and reach the city centre, with police firing tear gas and stun grenades.

But elsewhere Athenians young and old waited patiently in line to catch a glimpse of the leader on his last foreign trip as president.

"It's fantastic to be here," said 17-year-old pupil Anais Karayanis. "He has plenty of things to teach us, advice to give. I would have come to see Trump as well, but only out of pure curiosity because I don't support him."

Betty Kazakopoulos, a PR consultant in her 60s, said Obama was "a man I admire. Perhaps the last of the great American leaders."

- Greece's 'extraordinary compassion' -

During his visit to the cradle of democracy, Obama has also touched on issues that have shaken Greek society -- a dramatic influx of migrants fleeing war and poverty and a crippling financial crisis.

He lauded Greek islanders' "extraordinary compassion" for the hundreds of thousands of people who have landed on their shores since the start of Europe's worst migrant crisis since World War II.

And he pledged support for its economy, as Greek leaders seek a fresh US pledge to help alleviate the country's enormous public debt, a measure actively sought by the International Monetary Fund but opposed by leading European lender Germany.

"In my message to the rest of Europe, I will continue to emphasise our view that austerity alone cannot deliver prosperity," Obama told Greek Prime Minister Alexis Tsipras.