President Obama tours the Acropolis with Eleni Banou, of Greece's Ministry of Culture, on Nov. 16 in Athens. (Pablo Martinez Monsivais/AP)

ATHENS — In an address aimed at a global audience as well as Americans at home, President Obama said Wednesday that “the current path of globalization needs a course correction,” even as he argued there was no turning back from an interconnected world.

"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," he said.

The speech, given before a supportive crowd in the newly opened Stavros Niarchos Foundation Cultural Center, represented the third time in as many days that Obama has sought to grapple with the wave of political discontent that swept Donald Trump into the White House last week and has roiled politics in Europe as well as other regions of the world.

On Tuesday night, a few thousand globalization opponents sparred with police during protests in Athens.

Paying homage to Greece’s role as the birthplace of democracy, the president prompted a laugh when he said it was essential to defend ideals including freedom of speech, religion and “free and fair elections--because citizens must be able to choose their own leaders, even if your candidate doesn’t always win."

Greece, he added, gave humanity “the most precious of gifts -- the truth, the understanding that as individuals of free will, we have the right and the capacity to govern ourselves."

Every country " travels its own path, every country has its own traditions," Obama said. "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."

But he acknowledged that the kind of “inclusive economies” and social tolerance he espouses have come under strain, as the glaring inequality between the world’s economic classes has become more evident and different cultures have come into closer proximity with each other.

“Democracy is simplest where everybody thinks alike, looks alike, eats the same food, worships the same God,” Obama said. "An inequality that was once tolerated because people didn’t know how unequal things were now won’t be tolerated because everybody has a cellphone and can see how unequal things are."

“If people feel that they’re losing control of their future, they will push back,” he warned. “What an irony it is, at a time when we can reach out to people in the most remote corners of the planet, so many citizens feel disconnected from their own governments.”

Obama rose to global prominence by addressing tens of thousands of supporters outside in Berlin, but his speech Wednesday — which may be his final formal address overseas — was a more subdued affair. An audience of several hundred invited guests sat inside a hall that resembled an opera house or old-fashioned theater, with rings of balconies marked by ruby-red upholstery. The crowd clapped approvingly at several points during Obama’s remarks, but appeared more focused on his approving references to Greece’s economic plan and willingness to host refugees than his broader remarks.

President Obama gestures as he speaks at the Niarchos Foundation in Athens on November 16 at the end of his official visit to Greece. (Aris Messinis/AFP/Getty Images)

In an email last week, George Papandreou, who served as Greece's prime minister from 2009 to 2011, said it was essential that Obama address the issue of how to “humanize” and “democratize” globalization in order to defuse the “divisive politics of fear” that has begun to gain currency around the world.

“Globalization without caring for those who have become poorer, those in the middle class who have lost the prospect of a better life, those who are struggling with new technologies and fear the loss of jobs, those who feel helpless when confronted with rapid economic and technological change,” Papandreou said, “or so many that do not see the global community uniting in the fight against climate change, those who feel that the rich are getting richer and all others are getting poorer, simply will not fly.”

In his remarks, the president defended the idea of fashioning policies that knit the world more closely together while alleviating some of its economic ills. In a veiled allusion to Trump’s “Make America Great Again” campaign slogan, he said, “So we can’t look backwards for answers, we have to look forward.”

But he also said that “democracy is bigger than any one person,” and it was important to accept the results of any free election.

“We compete hard in campaigns in America and here in Greece,” he said. “But after the election, democracy depends on the peaceful transition of power.”

As Obama traveled through the streets of Athens, where schools were closed Wednesday, the city appeared largely deserted. The police imposed restrictions specifically for the president’s visit, though the city is also facing protests that will take place Thursday on the anniversary of a 1973 student uprising against Greece's then-military junta, and the assassination of the CIA station chief in Athens a revolutionary group carried out two years later.

Still, Obama was determined to do some sightseeing while in Greece. He began his second day here by touring the Acropolis, which was emptied out for the president and his entourage. Only a few stray cats, which regularly wander the ancient ruins, penetrated the security perimeter as the president received a guided tour from Eleni Banou, who directs the Ephorate of Antiquities for Athens at the Greek Ministry of Culture.

“Beautiful,” the president remarked to himself as he walked through the nearby Acropolis Museum, which was also closed to the public for his visit.

The visit amounted to a six-year-old rain check. In 2010, Papandreou invited the president to Greece during a visit to the White House: At the time Obama “mentioned that he would want to take his two beautiful daughters on donkey rides on a Greek island,” Papandreou recalled in an email. “The invitation is still valid.”

As Obama landed in Berlin on Wednesday and went into a private dinner with German Chancellor Angela Merkel, the two leaders took a joint stand in favor of globalization, free trade and combating climate change. In a joint opinion piece that seemed to push back against the campaign agenda of Donald Trump, they also hailed NATO — to which Trump as signaled a less than firm commitment — as vital to maintaining security and stability in the region.

In the piece — excerpted on Wednesday and to be published in full this week by the German weekly Wirtschaftwoche — the leaders argued that there “will be no return to a world before globalization.” They argued in favor of pursuing a free trade deal between the United States and the European Union despite Trump campaign pledges that seemed to doom it after years of negotiations.

They also stressed the need to push forward with the Paris Agreement on climate change struck last year to cut greenhouse emissions, and which Trump has said he plans to pull out of.

“It gives the world a framework for the common protection of our planet,” Merkel and Obama wrote.