Barack Obama has given a rousing defence of the virtues of democracy and warned that a backlash against globalisation is boosting populist movements around the world, in what was billed as his last public address abroad.

Speaking near the Acropolis of Athens, the outgoing US president said that democracy – like the version invented by the ancient Greeks “in this small, great world” – might still be imperfect, yet for all its flaws it fostered hope over fear.

“Even if progress follows a winding path – sometimes forward, sometimes back – democracy is still the most effective form of government ever devised by man,” Obama said.

We must rethink globalization, or Trumpism will prevail | Thomas Piketty Read more

“The flame first lit here in Athens never died. It was ultimately nurtured by a great enlightenment. It was fanned by America’s founders, who declared that: ‘We, the people shall rule; that all men are created equal and endowed by our creator with certain inalienable rights.”

Referencing a quote from Martin Luther King, he said democracy set people free and that allowed them to bend the arc of their lives towards justice.

Globalisation could not be rolled back, Obama told the audience at the newly built Stavros Niarchos cultural centre. He said that “we cannot sever the connections that have enabled so much progress” but cautioned that it was leading to increasing inequality around the world. Fast-moving technological innovation – as well as causing enormous disruption to many workers’ lives – was making it easier for people to see that inequality, the president added.

“The current path of globalisation demands a course correction,” he said. “In the years and decades ahead, our countries have to make sure that the benefits of an integrated global economy are more broadly shared by more people, and that the negative impacts are squarely addressed.

“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.”

In times of old, people had no idea how others lived. Now that was no longer the case, they had begun asking questions about their own identity. “And it can create a volatile politics.”

Facebook Twitter Pinterest Obama with Eleni Banou, ministry of culture director of Ephorate of Antiquities for Athens, during a tour of the Acropolis. Photograph: Brendan Smialowski/AFP/Getty Images

“In the Information Age, the unprecedented exchange of information can always accentuate differences, or seem to threaten cherished ways of life.”

That Obama should choose Athens as a backdrop – barely two months before he hands the keys of the White House to Donald Trump – was in itself filled with symbolism.

It wasn’t just that democracy was first conceived in “these rocky hills”, he said, or that he had long yearned to tour the Parthenon, which he did earlier in the day. Or even that he wished to show gratitude to all that Greece had given to humanity through the ages. The debt-stricken country has also been on the frontline of Europe’s twin economic and refugee crises and in the latter had shown “extraordinary compassion”.

“The world, I don’t think, fully appreciates the … tremendous sacrifices that you, the Greek people, have made,” he said to thunderous applause from an audience that included politicians, businessmen, human rights activists and refugees. “I’ve been aware of it, and I’ve been proud of all that my administration has done to try and support Greece in these efforts.”

For prime minister Alexis Tsipras’s leftist-led government, Obama’s 30-hour visit and repeated expression of support for its efforts to secure debt relief was an unexpected gift.

“It’s been incredible,” Nikos Pappas, a leading minister and Tsipras’ closest aide, told the Guardian. “He hasn’t been credited enough for the role he played saving Greece. He and Jack Lew [the treasury secretary] were on the phone all the time at the height of the [eurozone] crisis.”

For Obama, the farewell tour is as much about safeguarding his legacy as allaying the fears of European leaders after Trump’s surprise election.

Ex-Nato leaders call for extraordinary meeting with Donald Trump Read more

And for many, in Greece at least, there is trepidation about what the post-Obama era might bring.

But on Wednesday, the leader of the free world was determined to end his Athenian visit on an optimistic note, applauding those who – like the founders of democracy – had chosen hope over fear.

“I will say that after eights years of being president of the United States, having travelled around the globe, it is absolutely true that every country travels its own path, every country has its own traditions,” he continued. “But what I also believe, after eight years, is that the basic longing to live with dignity, the fundamental desire to have control of our lives and our future, and to want to be a part of determining the course of our communities and our nations – these yearnings are universal. They burn in every human heart.”

Obama’s speech, before an onward trip to Germany where he will meet the chancellor, Angela Merkel, as well as Theresa May and the French and Italian leaders François Hollande and Matteo Renzi, followed a morning tour of the Acropolis and its museum. It was the first official visit by a sitting US president since Bill Clinton.