The United States’ 102 historically black colleges and universities have always had a distinctive source of appeal: a chance for students of color to learn and mature without the lingering discrimination and overtly racist history that characterize many institutions of higher learning.

But at a political moment marked by racially divisive rhetoric — sometimes accompanied by deadly violence, most recently an avowed racist admitting to killing dozens at two mosques in New Zealand on Friday — some say HBCUs are looking more attractive than ever. That sentiment was voiced again and again Saturday at the 20th Annual Black College Expo held at Bowie State University in Maryland.

“It’s nice to be around people who can relate to you,” said Leon Smith, a 17-year-old from Upper Marlboro, Md., who attended the event. After the headlines of the past several years — including a deadly white-nationalist rally that took place in 2017 in Charlottesville, a less than three-hour drive from Bowie State — Smith said he felt “more comfortable” with the idea of pursuing his education among other black students.

After years of decline, enrollment at HBCUs is on the rise, according to federal data. Total enrollment in fall 2017 was 298,138, an increase of 2.1 percent over the previous year. That jump came even as across-the-board enrollment in all U.S. colleges and universities continued to fall.

Some admissions officials attribute the gains to increased outreach and marketing by historically black campuses, defined as those founded before 1964 to serve black students during an era of legal segregation. But others say that disquieting setbacks in national race relations have played a role.

“When you think about what happened in Virginia a few years ago and things like that — students want to be on a campus where they feel safe,” said Shanice Pereira, an admissions officer at Morgan State University in Baltimore. “It’s something that impacts students and their thinking.”

Theresa Price, founder and chief executive of the National College Resources Foundation, which hosts the Black College Expo, said students are increasingly coming to see HBCUs as a “safe haven” from racist views she says have become more openly expressed since the election of President Trump. “I think definitely the political environment has encouraged people to take a better look” at the schools, Price said.

Trump has repeatedly denied allegations that he is racist or encourages racist views. But the president — who trumpeted the conspiracy theory that former president Barack Obama was not born in the United States and launched his 2016 campaign with a speech in which he said that Mexican immigrants crossing the border were rapists — has come under fire while in office for his reactions to racist incidents.

Trump said there were “very fine people” as well as “very bad people” among the white nationalists who assembled in Charlottesville in 2017, an episode that culminated in rioting and the murder of 32-year-old Virginia resident Heather Heyer.

After shootings carried out Friday, allegedly by a man who subscribed to white-supremacist ideology, left 50 dead at two mosques in Christchurch, New Zealand, Trump said he did not believe white nationalism was a growing threat. “I think it’s a small group of people that have very, very serious problems. It’s certainly a terrible thing,” he said.

The prospect of racist violence also weighs on the minds of parents.

“You always want to be in a situation where you feel comfortable,” said Jesse White, a 41-year-old resident of Accokeek, Md., who was at the Black College Expo with his 18-year-old son. “And when you think about the political environment in this country right now. . . .”

He broke off, then spoke of the mass shooting in New Zealand.

“You look at what happened over there,” White said. He said that while he did not attend an HBCU, he is encouraging his son’s desire to do so.