ATHENS, Greece President Obama brought a message of reassurance to Greece -- even so, the questions that faced him at a news conference in Athens with Greek Prime Minister Alexis Tsipras were dominated by the recent election of Donald Trump.

In response to a question about whether he realized there was anger in the American populace before the election, the president said, “Of course I did.” But he acknowledged that the candidacies of both Democrat Bernie Sanders and of Donald Trump were able to tap into the anger and fear of many Americans.

“When you see a Donald Trump and a Bernie Sanders -- very unconventional candidates -- have considerable success, then obviously there’s something there that’s being tapped into,” Mr. Obama said. “A suspicion of globalization. A desire to rein in its excesses. A suspicion of elites and governing institutions that people feel may not be responsive to their immediate needs. And that sometimes gets wrapped up in issues of ethnic identity or religious identity or cultural identity. And that can be a volatile mix.”

President Obama said that world leaders need to pay heed to people’s very real fears of economic dislocation and inequality in the midst of globalization.

Get Breaking News Delivered to Your Inbox

“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,” Obama said as he opened the last foreign tour of his presidency.

The president said that both Trump’s election and the British vote to leave the European Union reflected the need to deal with “people’s fears that their children won’t do as well as they have.”

“Sometimes people just feel as if we want to try something and see if we can shake things up,” Obama said. And he said that in times of stress, people are going to be looking for something. “They might not know what they’re looking for,” Mr. Obama said, “and they may opt for change, even if they’re not entirely confident what that change will bring.”

The president seemed skeptical that “the new prescriptions being offered” would satisfy the frustrations and anger evident in both votes. And he played a bit of defense, saying that his agenda over past eight years had dealt with those issues head on and “the country’s indisputably better off.”

The president earlier opened his Greek visit by offering reassuring words in Greece about the U.S. commitment to NATO even as he prepares to hand off to a Donald Trump administration, saying Democratic and Republican administrations alike recognize the importance of the alliance to the trans-Atlantic relationship.

Mr. Obama told Greek President Prokopis Pavlopoulos that a strong NATO is of “utmost importance” and would provide “significant continuity even as we see a transition in government in the United States.”

Pavlopoulos, for his part, thanked President Obama for U.S. support of the Greek people in a time of social and economic crisis, and said he was confident that Trump “will continue on the same path.”

Trump’s election has generated significant unease in Europe because of his tough talk during the campaign suggesting the U.S. might pull out of the NATO alliance if other countries don’t pay more.

Mr. Obama’s reassurances reflect an attempt to ease the deep concerns about Trump and the future of America’s treaty alliances. Yet they may be greeted with skepticism: For months throughout the campaign, President Obama repeatedly assured world leaders in public and private that Trump would not be elected, only to see him emerge victorious from last week’s election.

The president also met Tuesday with Greek Prime Minister Alexis Tsipras, and offered a welcome message of support for the Greeks as they struggle with both economic woes and a huge influx of refugees. The presidetnpledged to keep pressing his view that “austerity alone cannot deliver prosperity and that it is going to be important both with respect to debt relief and other accommodative strategies to help the Greek people in this period of adjustment.”

Mr. Obama is making the first visit to Greece by a sitting U.S. president since Bill Clinton in 1999. Security was tight, with major roads shut down along President Obama’s motorcade route and a ban on public gatherings and demonstrations in swaths of central Athens and a southern suburb near a seaside luxury hotel where he was staying. Boats were also banned from sailing near the coastline at the hotel’s location.

More than 5,000 police were deployed in the capital’s streets for the two-day visit. Left-wing and anarchist groups have planned protest demonstrations for Tuesday afternoon, while an armed anarchist group has called for “attacks and clashes” to disrupt Mr. Obama’s visit. Clinton’s visit, which came during the height of U.S. intervention in the wars ensuing from the breakup of Yugoslavia, was marked with extensive violent demonstrations.

On Wednesday, Mr. Obama is scheduled to tour the Acropolis and give a major speech about democracy and globalization before flying on to Berlin. From Germany, he will travel to Peru for an Asian economic summit before returning to Washington on Saturday.

President Obama said he was looking forward to visiting the Acropolis because “if you come to Greece you’ve got to do a little bit of sightseeing.”

Greece’s government has hailed the president’s visit as being of “huge importance” for both Greece and Europe. The country’s left-led coalition government has been struggling to pull Greece out of six years of a vicious financial crisis that has devastated its economy and left more than a quarter of the workforce unemployed. Despite the U.S. election, the government has pinned its hopes on the U.S. president to help persuade some of the country’s more reluctant international creditors, such as Germany, to grant it significant debt relief.

Without a cut in its debt, Athens says, it cannot hope to recover economically - an argument also supported by the International Monetary Fund.

Greece has been relying on emergency loans from three consecutive multi-billion euro bailouts from other European Union countries using the euro currency, and the IMF, since 2010. While the United States has not been involved in Greece’s bailout, Athens has long seen it as an ally that could apply pressure on creditors.

The U.S. has praised Greek efforts to overhaul its economy but has repeatedly stressed the country must continue with painful reforms. The country’s bailout funds are disbursed following reviews by international debt inspectors of mandated reforms.

The government will also be looking for recognition of the country’s role in Europe’s refugee crisis, which saw hundreds of thousands of refugees pass through Greece from Turkey on their way to the more prosperous countries of the European north, and for U.S. pressure on the rest of Europe to help shoulder the burden.