President Obama waves as he arrives to deliver a speech at the University of Indonesia in Jakarta on Nov. 10, 2010. He said he thought of the visit as a homecoming because he lived in Indonesia for four years as a boy. (Jim Watson/AFP/Getty Images)

When Barack Obama visited Jakarta in 2010, on his first state visit to Indonesia, university students lined up outside the hall starting at 4 a.m., eager to catch a glimpse of the American president who had spent four years of his youth here.

Arlian Buana, a journalist who was a student at the time, remembers Obama’s eloquent speech about how his childhood in Jakarta exposed him to the basic goodness of Islam. “Obama wanted to show that Indonesia offered a model for how Islam and democracy could be compatible,” Arlian remembered. “Not since [former president] Sukarno has Indonesia witnessed such an amazing orator.”

Obama lived here from 1967, when he was 6 years old, to 1971, after his mother had married an Indonesian geographer. He went to Indonesian-language schools, and in his memoir, “Dreams from My Father,” he wrote about the contentment he felt living in that society.

News of his election in 2008 was greeted ecstatically here, and though there have been inevitable feelings of disappointment since then, Indonesians still savor their connection to the U.S. president.

Pew data shows that Indonesian approval of the United States rose to about 70 percent shortly after Obama was elected, from around 30 percent during the George W. Bush years. Indonesian approval of the United States has remained well above 50 percent throughout Obama’s presidency.

But with that presidency drawing to a close, America’s approval rating is set to take a tumble in Indonesia, the country that has more Muslims than any other nation in the world. President-elect Donald Trump’s negative views of Islam, and his declaration that the United States should restrict Muslim immigration, have been widely disseminated and condemned in Indonesia.

Dino Djalal, who was Indonesia’s ambassador to the United States from 2010 to 2013, wrote in a post for the Foreign Policy Community of Indonesia that he was concerned Trump’s attitudes toward Islam could damage American-Indonesian relations. “If Donald Trump restricts Muslim immigration to the United States, the Indonesian government must speak up, even if that means raising the issue with the Organization of Islamic Cooperation,” Dino wrote. He expressed hope that Trump would moderate his positions once in office.

The concerns about Trump go beyond his views on Islam. Indonesian economists and politicians worry that if America becomes more protectionist, other countries will respond in kind, which could ultimately damage Indonesian exports.

Dewi Fortuna Anwar, a prominent Indonesian foreign-policy thinker who serves as deputy secretary to Vice President Jusuf Kalla, was especially worried about Trump’s talk of abandoning America’s allies in the region.

“I was appalled, simply appalled, when Donald Trump said in one of his many speeches that he would like to see Japan become a nuclear power,” Dewi said. “That is a recipe for disaster.”

Dewi warned that Indonesia’s continued economic growth is dependent on regional stability.

“A lot of the economic gains would be lost,” she said, if Asian countries engage in an arms race so they can protect themselves without relying on the U.S. nuclear umbrella.

The anxiety that Indonesians feel in the weeks after Trump’s victory couldn’t contrast more strongly with the jubilation when Obama was elected. Eight years ago, then-President Susilo Bambang Yudhoyono congratulated Obama by reminding the new president of his deep ties to Indonesia, with local fans financing a $10,000 bronze statue of Obama as a boy living in Jakarta.

When Obama visited Indonesia in 2010, he referred to it as a homecoming, and emphasized the similarities between the United States and Indonesia, the world’s second- and third-largest democracies. “We are two nations which have traveled different paths,” Obama said at the time. “Yet our nations show that hundreds of millions who hold different beliefs can be united in freedom under one flag.”

The bronze statue now sits in the courtyard of the leafy public school Obama attended in the center of the city. Edi Kusyanti, director of State Elementary School Menteng 1, said that every student here is taught that Obama is kind and hard-working. Edi saw these attributes reflected in the Obama presidency.

Evan Laksmana, a research fellow at the Center for Strategic and International Studies in Jakarta, says that Obama has left important legacies In Indonesia. An agreement between the United States and Indonesia, signed in 2010, created groups to build partnerships on climate change and the environment, and significantly increased the amount of Fulbright foreign-exchange scholarships offered by the U.S. government to American and Indonesian students and academics. It’s “less of a high-profile thing, but it’s actually a good thing,” Laksmana said.

He acknowledged that some in Indonesia’s foreign-policy community say that Obama’s Pivot to Asia was underwhelming and they are disappointed that ties between the United States and Indonesia did not ramp up significantly during his presidency.

“It’s the expectations game. Precisely because Obama was supposed to have this epic relationship with Indonesia, we would [expect to] see more high-profile activities and events between the two countries,” Laksmana said. But, he said, by enhancing person-to-person ties, the Obama administration created “strong ballast” in the relationship.

Now there is concern that Trump’s anti-Islam rhetoric could undermine that. Rizki Andini, a 25-year-old Indonesian student from Jakarta’s suburbs, said that she had wanted to pursue a master’s degree in the United States beginning two years ago, but became anxious after hearing about attacks such as the 2015 Chapel Hill, N.C., shootings, when three Arab American Muslims were killed by a man with a history of making anti-Muslim statements.

“This [anxiety] increased after Trump’s racist and Islamaphobic campaign, which I didn’t expect to receive such strong [public] support. It made me reconsider my desire to study in the United States,” Rizki said. Ultimately, she said, the rise of Trump was one reason she turned down a Fulbright fellowship and instead took an Australian scholarship.

Alan Feinstein, director of the American Indonesian Exchange Foundation, which oversees the Fulbright program to Indonesia, acknowledged in an email Indonesian anxieties about studying in the United States.

“Ever since the campaign began and since Trump’s statements about barring Muslims’ entry to the U.S. or setting up a registry [for Muslims], et cetera, Indonesians have asked us what this means for those wanting to study in the U.S.,” he said.

For Arlian, the Indonesian who was impressed by Obama’s speech during his state visit, it was disappointing that Trump won the election after saying such negative things about Islam. But Arlian understood how it could happen.

He noted that Indonesia, itself a large, plural democracy, has, like many countries around the world, seen a rise in sectarian rhetoric directed against religious and ethnic minorities, such as Christians and ethnic-Chinese Indonesians.

“Trump represents their frustrations,” Arlian said. “This is what democracy is like. Maybe it will happen to Indonesia in a few years.”

But he hopes it won’t.