When Mak Kapetanovic saw the screed connected to the alleged gunman who attacked two mosques in Christchurch, New Zealand, he immediately recognized the obscure internet references and the racist ideology.

Kapetanovic, 22, of Jacksonville, Florida, once subscribed to those beliefs and frequented the same dark corners of the internet that are now the target of international condemnation. Since Christchurch, two more mass shootings have been connected to internet-fueled extremism.

But Kapetanovic got out.

“I grew up on the same memes that probably the New Zealand shooter did,” he said. “And a lot of the same ideas were fed to both of us, but he killed 50 people, and now I'm fighting against that ideology.”

Internet-born race-based extremism has emerged as a national topic of discussion due primarily to recent public acts of mass violence by people who also posted ideological screeds that provided a roadmap to how they were radicalized.

Those screeds have detailed how both mainstream platforms and fringe internet forums can lead people — most notably young men — to white supremacist rhetoric. Researchers have found that the digital ecosystem that has fostered and promoted extremist content has evolved over a handful of years, thanks in part to platforms like YouTube that have been financially incentivized to recommend videos with the most emotional impact to its users.

How do white supremacist groups recruit people? @byjacobward explains: pic.twitter.com/MLD0LuJ7TD — Velshi & Ruhle (@VelshiRuhle) August 5, 2019

Even online content that might seem relatively benign, such as a self-improvement video series for young men or blog posts skeptical of scientific findings, can be a gateway to darker ideas.

“Social networking between influencers makes it easy for audience members to be incrementally exposed to, and come to trust, ever more extremist political positions,” writes Rebecca Lewis, a misinformation researcher at Data & Society, a nonprofit research institute.

Political conversation about U.S. domestic extremism and terror have tended to focus on the threat by radical Islamists. But according to a recent report by the U.S. Government Accountability Office, from the day after 9/11 to Dec. 31, 2016, there were 85 fatal attacks in America by violent extremists. Two-thirds were carried out by far-right violent extremists and the remainder by radical Islamists.

Increasingly, those extremists are finding each other and luring in new people online.

Kapetanovic told NBC News how he came to follow a variety of extremist beliefs — including some that denigrated his own Muslim heritage — but was later able to escape the cycle of digital hate and eventually confessed his thoughts to his father. He said that his own experience shows just how unprepared the nation is for digital platforms that make it easy for people to become radicalized.

“We as a society, we've never really had to deal with ideas spreading in this way,” he said. “The internet is very, very young. And so this is the first really big, hateful movement that's being spread online. And I don't think anyone is really properly addressing it or talking about it.”

While white supremacy and other extremist ideologies have existed — and at times thrived — in the U.S. since before the internet, digital platforms have provided historically unparalleled ways to disseminate and repackage its propaganda.

Christian Picciolini, a former white supremacist who now works to rehabilitate extremists, said extremist recruitment that previously happened in person now happens online.

“With the internet, it's as if there is a 24-hour hate buffet online for young people to really start to find these narratives,” said Picciolini, the founder of the Free Radicals Project, a nonprofit that provides intervention assistance and training for violent extremists. “For a 14-year-old who may stumble on some sort of a propaganda video, they'll be fed more of those videos. And essentially, the internet and the algorithms are working to radicalize us if we land in the wrong place.”

Kapetanovic’s story echoes what Picciolini and extremism researchers have found. A second-generation Muslim American, he was raised by his parents who emigrated from Bosnia.

Kapetanovic said he felt isolated growing up, traveling lost distances to attend a magnet school and having few friends. His mother’s sudden death when he was 16 only made him feel more isolated and depressed, he said.

Already drawn to provocative literature and libertarian and atheist beliefs, he said he began searching online for information about his own identity, immigration and science.

From there, Kapetovic said the platforms he searched kept driving him toward more and more outrageous and addictive propaganda.

“There was a lot of just casual racism,” he recalled, and either verbal conversation or text posts pointed him to other online forums.

From there, he said he began investigating questions about the genetic differences between the races on sites like YouTube, Reddit and 4chan, eventually coming to believe that Muslims are inherently violent, that Caucasians are somehow superior to other races, and other forms of discriminatory pseudoscience.

While some of his content choices were conscious, Kapetanovic said he was also served a variety of other ideas through automated systems, such as YouTube’s recommendation algorithm.

“You can go in five clicks from doing your homework to white supremacist videos,” he said.

Kapetanovic said he wound up believing propaganda that implicated his own background.

“I come from a Muslim family. I come from an immigrant family. I come from a place where during the war, people like me that were ethnically Muslim were ethnically cleansed,” he said. For him, he said, he still can’t believe he was “OK with the kind of ideas that I was OK with. I mean, that's surreal.”

Reading material online had drawn Kapetanovic into this hateful world. But it was also his way out.

“I thought that these arguments made sense to me, and that if they made sense, they should logically be able to hold up against whatever other people may think or throw at me,” he said. “I'm going to go see what this other side believes."

He read the studies and source documents that the supremacists were citing to support their beliefs. It took him days to pore through the dense, jargon-filled documents, but eventually he realized they were riddled with problems.

“Just insane methodological errors. No serious person would consider this sound science,” he said. “And, of course, all these things are omitted when they're spoken by white nationalists to other people.”

Kapetanovic said he has learned to read credible sources. He now attends the University of North Florida and is studying sociology, anthropology and social work.

CORRECTION (Aug 12, 2019, 4:09 p.m. ET): A previous version of this article misstated Mak Kapetanovic's age when his mother died. He was 16, not 14.