Caleb Cain was a college dropout looking for direction. He turned to YouTube. Soon, he was pulled into a far-right universe, watching thousands of videos filled with conspiracy theories, misogyny and racism. “I was brainwashed.” The Making of a YouTube Radical A sampling of the more than 12,000 videos that Caleb Cain watched going back to 2015, many but not all of which were from far-right commentators.

Martinsburg, W.Va. — Caleb Cain pulled a Glock pistol from his waistband, took out the magazine and casually tossed both onto the kitchen counter.

“I bought it the day after I got death threats,” he said.

The threats, Mr. Cain explained, came from right-wing trolls in response to a video he had posted on YouTube a few days earlier. In the video, he told the story of how, as a liberal college dropout struggling to find his place in the world, he had gotten sucked into a vortex of far-right politics on YouTube.

“I fell down the alt-right rabbit hole,” he said in the video.

Mr. Cain, 26, recently swore off the alt-right nearly five years after discovering it, and has become a vocal critic of the movement. He is scarred by his experience of being radicalized by what he calls a “decentralized cult” of far-right YouTube personalities, who convinced him that Western civilization was under threat from Muslim immigrants and cultural Marxists, that innate I.Q. differences explained racial disparities, and that feminism was a dangerous ideology.

“I just kept falling deeper and deeper into this, and it appealed to me because it made me feel a sense of belonging,” he said. “I was brainwashed.”

Caleb Cain. Justin T. Gellerson for The New York Times

Over years of reporting on internet culture, I’ve heard countless versions of Mr. Cain’s story: an aimless young man — usually white, frequently interested in video games — visits YouTube looking for direction or distraction and is seduced by a community of far-right creators.

Some young men discover far-right videos by accident, while others seek them out. Some travel all the way to neo-Nazism, while others stop at milder forms of bigotry.

The common thread in many of these stories is YouTube and its recommendation algorithm, the software that determines which videos appear on users’ home pages and inside the “Up Next” sidebar next to a video that is playing. The algorithm is responsible for more than 70 percent of all time spent on the site.

The radicalization of young men is driven by a complex stew of emotional, economic and political elements, many having nothing to do with social media. But critics and independent researchers say YouTube has inadvertently created a dangerous on-ramp to extremism by combining two things: a business model that rewards provocative videos with exposure and advertising dollars, and an algorithm that guides users down personalized paths meant to keep them glued to their screens.

“There’s a spectrum on YouTube between the calm section — the Walter Cronkite, Carl Sagan part — and Crazytown, where the extreme stuff is,” said Tristan Harris, a former design ethicist at Google, YouTube’s parent company. “If I’m YouTube and I want you to watch more, I’m always going to steer you toward Crazytown.”

“I’m just a Bill, but I’d like to be Jill, and I’m demanding bathroom access at will.” I'm Just a Bill (Transgender Schoolhouse Rock Parody!) — Steven Crowder Steven Crowder, a conservative commentator, has gained nearly four million subscribers like Mr. Cain with shock-jock antics like this parody, which drew from a widely recognized “Schoolhouse Rock” cartoon.

In recent years, social media platforms have grappled with the growth of extremism on their services. Many platforms have barred a handful of far-right influencers and conspiracy theorists, including Alex Jones of Infowars, and tech companies have taken steps to limit the spread of political misinformation.

YouTube, whose rules prohibit hate speech and harassment, took a more laissez-faire approach to enforcement for years. This past week, the company announced that it was updating its policy to ban videos espousing neo-Nazism, white supremacy and other bigoted views. The company also said it was changing its recommendation algorithm to reduce the spread of misinformation and conspiracy theories.

With two billion monthly active users uploading more than 500 hours of video every minute, YouTube’s traffic is estimated to be the second highest of any website, behind only Google.com. According to the Pew Research Center, 94 percent of Americans ages 18 to 24 use YouTube, a higher percentage than for any other online service.

Like many Silicon Valley companies, YouTube is outwardly liberal in its corporate politics. It sponsors floats at L.G.B.T. pride parades and celebrates diverse creators, and its chief executive endorsed Hillary Clinton in the 2016 presidential election. President Trump and other conservatives have claimed that YouTube and other social media networks are biased against right-wing views, and have used takedowns like those announced by YouTube on Wednesday as evidence for those claims.

In reality, YouTube has been a godsend for hyper-partisans on all sides. It has allowed them to bypass traditional gatekeepers and broadcast their views to mainstream audiences, and has helped once-obscure commentators build lucrative media businesses.

It has also been a useful recruiting tool for far-right extremist groups. Bellingcat, an investigative news site, analyzed messages from far-right chat rooms and found that YouTube was cited as the most frequent cause of members’ “red-pilling” — an internet slang term for converting to far-right beliefs. A European research group, VOX-Pol, conducted a separate analysis of nearly 30,000 Twitter accounts affiliated with the alt-right. It found that the accounts linked to YouTube more often than to any other site.

“YouTube has been able to fly under the radar because until recently, no one thought of it as a place where radicalization is happening,” said Becca Lewis, who studies online extremism for the nonprofit Data & Society. “But it’s where young people are getting their information and entertainment, and it’s a space where creators are broadcasting political content that, at times, is overtly white supremacist.”

I visited Mr. Cain in West Virginia after seeing his YouTube video denouncing the far right. We spent hours discussing his radicalization. To back up his recollections, he downloaded and sent me his entire YouTube history, a log of more than 12,000 videos and more than 2,500 search queries dating to 2015.

These interviews and data points form a picture of a disillusioned young man, an internet-savvy group of right-wing reactionaries and a powerful algorithm that learns to connect the two. It suggests that YouTube may have played a role in steering Mr. Cain, and other young men like him, toward the far-right fringes.

It also suggests that, in time, YouTube is capable of steering them in very different directions.

Here Are the Number of Political Videos Cain Watched Each Month 0 views 40 80 120 160 200 The right-wing content Mr. Cain viewed in 2015 and 2016 often consisted of videos by Stefan Molyneux, with titles like “Social Justice Warriors Always Lie” and “The Global Warming Hoax.” Mr. Cain also watched many videos by members of the so-called intellectual dark web, like the popular comedian Joe Rogan and the political commentator Dave Rubin. During 2017, Mr. Cain began watching more videos from left-wing channels. 0 views 40 80 120 160 200 0 40 80 120 160 200 views The right-wing content Mr. Cain viewed in 2015 and 2016 often consisted of videos by Stefan Molyneux, with titles like “Social Justice Warriors Always Lie” and “The Global Warming Hoax.” Mr. Cain also watched many videos by members of the so-called intellectual dark web, like the popular comedian Joe Rogan and the political commentator Dave Rubin. During 2017, Mr. Cain began watching more videos from left-wing channels. 0 40 80 120 160 200 views Includes views of YouTube channels Mr. Cain viewed 10 times or more between mid-2015 and late 2018. Sources: Caleb Cain and YouTube

From an early age, Mr. Cain was fascinated by internet culture. As a teenager, he browsed 4Chan, the lawless message board. He played online games with his friends, and devoured videos of intellectuals debating charged topics like the existence of God.

The internet was an escape. Mr. Cain grew up in postindustrial Appalachia and was raised by his conservative Christian grandparents. He was smart, but shy and socially awkward, and he carved out an identity during high school as a countercultural punk. He went to community college, but dropped out after three semesters.

Broke and depressed, he resolved to get his act together. He began looking for help in the same place he looked for everything: YouTube.

One day in late 2014, YouTube recommended a self-help video by Stefan Molyneux, a Canadian talk show host and self-styled philosopher.

Like Mr. Cain, Mr. Molyneux had a difficult childhood, and he talked about overcoming hardships through self-improvement. He seemed smart and passionate, and he wrestled with big questions like free will, along with practical advice on topics like dating and job interviews.

Mr. Molyneux, who describes himself as an “anarcho-capitalist,” also had a political agenda. He was a men’s rights advocate who said that feminism was a form of socialism and that progressive gender politics were holding young men back. He offered conservative commentary on pop culture and current events, explaining why Disney’s “Frozen” was an allegory about female vanity, or why the fatal shooting of an unarmed black teenager by a white police officer was proof of the dangers of “rap culture.”

Mr. Cain was a liberal who cared about social justice, worried about wealth inequality and believed in climate change. But he found Mr. Molyneux’s diatribes fascinating, even when they disagreed.

“He was willing to address young men’s issues directly, in a way I’d never heard before,” Mr. Cain said.

In 2015 and 2016, as Mr. Cain dived deeper into his YouTube recommendations, he discovered an entire universe of right-wing creators.

Here’s a 48-Hour Snapshot of What Cain Watched in 2015 A two-day sample of Mr. Cain’s YouTube history shows how steeped he was in far-right commentary from creators like Stefan Molyneux and Paul Joseph Watson. He viewed conspiracy theories and graphic violence, including a clip of a politician’s 1987 suicide. Feminism was a recurring theme. In one video, an English professor argued that feminism limited basic liberties. By the end of the binge, Mr. Cain had watched explicitly racist videos, including some from channels that have since been banned.

Over time, he watched dozens of clips by Steven Crowder, a conservative comedian, and Paul Joseph Watson, a prominent right-wing conspiracy theorist who was barred by Facebook this year. He became entranced by Lauren Southern, a far-right Canadian activist, whom he started referring to as his “fashy bae,” or fascist crush.

These people weren’t all shouty demagogues. They were entertainers, building their audience with satirical skits, debates and interviews with like-minded creators. Some of them were part of the alt-right, a loose cohort of pro-Trump activists who sandwiched white nationalism between layers of internet sarcasm. Others considered themselves “alt-lite,” or merely antiprogressive.

These creators were active on Facebook and Twitter, too. But YouTube was their headquarters, and the place where they could earn a living by hawking merchandise and getting a cut of the money spent on advertisements that accompanied their videos.

Few of them had overt ties to establishment conservative groups, and there was little talk about tax cuts or trade policy on their channels. Instead, they rallied around issues like free speech and antifeminism, portraying themselves as truth-telling rebels doing battle against humorless “social justice warriors.” Their videos felt like episodes in a long-running soap opera, with a constant stream of new heroes and villains.

To Mr. Cain, all of this felt like forbidden knowledge — as if, just by watching some YouTube videos, he had been let into an exclusive club.

“When I found this stuff, I felt like I was chasing uncomfortable truths,” he told me. “I felt like it was giving me power and respect and authority.”

If alienation was one ingredient in Mr. Cain’s radicalization, and persuasive partisans like Mr. Molyneux were another, the third was a series of product decisions YouTube made starting back in 2012.

In March that year, YouTube’s engineers made an update to the site’s recommendations algorithm. For years, the algorithm had been programmed to maximize views, by showing users videos they were likely to click on. But creators had learned to game the system, inflating their views by posting videos with exaggerated titles or choosing salacious thumbnail images.

In response, YouTube’s executives announced that the recommendation algorithm would give more weight to watch time, rather than views. That way, creators would be encouraged to make videos that users would finish, users would be more satisfied and YouTube would be able to show them more ads.

The bet paid off. Within weeks of the algorithm change, the company reported that overall watch time was growing, even as the number of views shrank. According to a 2017 report, YouTube’s watch time grew 50 percent a year for three consecutive years.

A month after its algorithm tweak, YouTube changed its rules to allow all video creators to run ads alongside their videos and earn a portion of the revenue they generated. Previously, only popular channels that had been vetted by YouTube were able to run ads.

Neither of these changes was intended to benefit the far right, and YouTube’s algorithm had no inherent preference for extreme political content. It treated a white nationalist monologue no differently from an Ariana Grande cover or a cake icing tutorial.

But the far right was well positioned to capitalize on the changes. Many right-wing creators already made long video essays, or posted video versions of their podcasts. Their inflammatory messages were more engaging than milder fare. And now that they could earn money from their videos, they had a financial incentive to churn out as much material as possible.

A few progressive YouTube channels flourished from 2012 to 2016. But they were dwarfed by creators on the right, who had developed an intuitive feel for the way YouTube’s platform worked and were better able to tap into an emerging wave of right-wing populism.

“I’m not sure the left understands the monumental ass-whupping being dished out to them on YouTube,” Mr. Watson, the conspiracy theorist, tweeted in 2017.

“The sexist, racist, homophobic narrative has been blown out of proportion and sensationalized, and everybody knows it.” ‘White Privilege’ is a dangerous myth — Lauren Southern Mr. Cain turned to videos like this one in late 2015, in part because of how Lauren Southern mocked feminism and "social justice warriors.”

Several current and former YouTube employees, who would speak only on the condition of anonymity because they had signed confidentiality agreements, said company leaders were obsessed with increasing engagement during those years. The executives, the people said, rarely considered whether the company’s algorithms were fueling the spread of extreme and hateful political content.

Guillaume Chaslot, a former YouTube engineer who has since become a critic of the company’s recommendation system, said this year that YouTube’s algorithms were designed to “increase the time people spend online, because it leads to more ads.”

In 2015, a research team from Google Brain, Google’s much-lauded artificial intelligence division, began rebuilding YouTube’s recommendation system around neural networks, a type of A.I. that mimics the human brain. In a 2017 interview with the Verge, a YouTube executive said the new algorithm was capable of drawing users deeper into the platform by figuring out “adjacent relationships” between videos that a human would never identify.

The new algorithm worked well, but it wasn’t perfect. One problem, according to several of the current and former YouTube employees, is that the A.I. tended to pigeonhole users into specific niches, recommending videos that were similar to ones they had already watched. Eventually, users got bored.

Google Brain’s researchers wondered if they could keep YouTube users engaged for longer by steering them into different parts of YouTube, rather than feeding their existing interests. And they began testing a new algorithm that incorporated a different type of A.I., called reinforcement learning.

The new A.I., known as Reinforce, was a kind of long-term addiction machine. It was designed to maximize users’ engagement over time by predicting which recommendations would expand their tastes and get them to watch not just one more video but many more.

Reinforce was a huge success. In a talk at an A.I. conference in February, Minmin Chen, a Google Brain researcher, said it was YouTube’s most successful launch in two years. Sitewide views increased by nearly 1 percent, she said — a gain that, at YouTube’s scale, could amount to millions more hours of daily watch time and millions more dollars in advertising revenue per year. She added that the new algorithm was already starting to alter users’ behavior.

“We can really lead the users toward a different state, versus recommending content that is familiar,” Ms. Chen said.

After being shown a recording of Ms. Chen’s talk, a YouTube spokesman confirmed that the company had incorporated reinforcement learning in its recommendation system. But he disputed her claim that it was YouTube’s most successful change in two years. He added that reinforcement learning was meant to make recommendations more accurate, by neutralizing the system’s bias toward popular content.

But YouTube’s changes again played into the hands of far-right creators, many of whom already specialized in creating videos that introduced viewers to new ideas. They knew that a video calling out left-wing bias in “Star Wars: The Force Awakens” might red-pill movie buffs, or that a gamer who ranted about feminism while streaming his Call of Duty games might awaken other politically minded gamers. And now YouTube’s algorithm was looking to promote the same kind of cross-genre exploration.

“The recent reboot by J.J. Abrams deepens and extends the glowing mayhem and radical antifamily message of the original series.” The Truth About Star Wars: The Force Awakens — Stefan Molyneux This “Star Wars” video is a prime example of how Mr. Molyneux is adept at drawing in new viewers by making political points out of pop culture.

YouTube’s recommendations system is not set in stone. The company makes many small changes every year, and has already introduced a version of its algorithm that is switched on after major news events to promote videos from “authoritative sources” over conspiracy theories and partisan content. This past week, the company announced that it would expand that approach, so that a person who had watched a series of conspiracy theory videos would be nudged toward videos from more authoritative news sources. It also said that a January change to its algorithm to reduce the spread of so-called “borderline” videos had resulted in significantly less traffic to those videos.

In interviews, YouTube officials denied that the recommendation algorithm steered users to more extreme content. The company’s internal testing, they said, has found just the opposite — that users who watch one extreme video are, on average, recommended videos that reflect more moderate viewpoints. The officials declined to share this data, or give any specific examples of users who were shown more moderate videos after watching more extreme videos.

The officials stressed, however, that YouTube realized it had a responsibility to combat misinformation and extreme content.

“While we’ve made good progress, our work here is not done, and we will continue making more improvements this year,” a YouTube spokesman, Farshad Shadloo, said in a statement.

By the night of Nov. 8, 2016, Mr. Cain’s transformation was complete.

He spent much of the night watching clips of Ms. Clinton’s supporters crying after the election was called in Mr. Trump’s favor. His YouTube viewing history shows that at 1:41 a.m., just before bed, he turned on a live stream hosted by Mr. Crowder, with the title “TRUMP WINS!”

“It felt like a punk-rock moment, almost like being in high school again,” Mr. Cain said.

That year, Mr. Cain’s YouTube consumption had skyrocketed. He got a job packing boxes at a furniture warehouse, where he would listen to podcasts and watch videos by his favorite YouTube creators all day. He fell asleep to YouTube videos at night, his phone propped up on a pillow. In all, he watched nearly 4,000 YouTube videos in 2016, more than double the number he had watched the previous year.

Not all of these videos were political. Mr. Cain’s viewing history shows that he sought out videos about his other interests, including cars, music and cryptocurrency trading. But the bulk of his media diet came from far-right channels. And after the election, he began exploring a part of YouTube with a darker, more radical group of creators.

These people didn’t couch their racist and anti-Semitic views in sarcastic memes, and they didn’t speak in dog whistles. One channel run by Jared Taylor, the editor of the white nationalist magazine American Renaissance, posted videos with titles like “‘Refugee’ Invasion Is European Suicide.” Others posted clips of interviews with white supremacists like Richard Spencer and David Duke.

Mr. Cain never bought into the far right’s most extreme views, like Holocaust denial or the need for a white ethnostate, he said. Still, far-right ideology bled into his daily life. He began referring to himself as a “tradcon” — a traditional conservative, committed to old-fashioned gender norms. He dated an evangelical Christian woman, and he fought with his liberal friends.

“It was kind of sad,” said Zelda Wait, a friend of Mr. Cain’s from high school. “I was just, like: ‘Wow, what happened? How did you get this way?’”

Some of Mr. Cain’s favorite YouTube creators were shifting their politics, too.

Mr. Molyneux, in particular, seemed to be veering further to the right. He fixated on “race realism,” a favored topic of white nationalists, and went on an Infowars show to discuss his opposition to multiculturalism with Mr. Jones. He hosted far-right figures on his channel, including Mr. Taylor of American Renaissance and Brittany Pettibone, a self-described “American nationalist” who pushed the Pizzagate conspiracy theory.

As Mr. Molyneux promoted white nationalists, his YouTube channel kept growing. He now has more than 900,000 subscribers, and his videos have been watched nearly 300 million times. Last year, he and Ms. Southern — Mr. Cain’s “fashy bae” — went on a joint speaking tour in Australia and New Zealand, where they criticized Islam and discussed what they saw as the dangers of nonwhite immigration.

In March, after a white nationalist gunman killed 50 Muslims in a pair of mosques in Christchurch, New Zealand, Mr. Molyneux and Ms. Southern distanced themselves from the violence, calling the killer a left-wing “eco-terrorist” and saying that linking the shooting to far-right speech was “utter insanity.”

Neither Mr. Molyneux nor Ms. Southern replied to a request for comment. The day after my request, Mr. Molyneux uploaded a video titled “An Open Letter to Corporate Reporters,” in which he denied promoting hatred or violence and said labeling him an extremist was “just a way of slandering ideas without having to engage with the content of those ideas.”

As social media platforms have barred far-right activists for hate speech, harassment and other harmful conduct, Mr. Molyneux and Ms. Southern have become vocal free-speech advocates who denounce what they call excessive censorship by social media companies.

“If you ban or crush people’s lawful speech, it’s like a rattlesnake,” Mr. Molyneux said in a video. “You cut off the rattle, but you don’t cut off the head.”

In 2018, nearly four years after Mr. Cain had begun watching right-wing YouTube videos, a new kind of video began appearing in his recommendations.

These videos were made by left-wing creators, but they mimicked the aesthetics of right-wing YouTube, down to the combative titles and the mocking use of words like “triggered” and “snowflake.”

“Enjoyment of Beethoven or white babies or whatever you get off to is in no way impeded by the proximity of people with different skin colors.” Decrypting the Alt-Right: How to Recognize a F@scist — ContraPoints Mr. Cain says Natalie Wynn, a former academic philosopher who makes left-wing YouTube videos, used humor, shot in a style not unlike right-wing creators, to get his attention.

One video was a debate about immigration between Ms. Southern and Steven Bonnell, a liberal YouTuber known as Destiny. Mr. Cain watched the video to cheer on Ms. Southern, but Mr. Bonnell was a better debater, and Mr. Cain reluctantly declared him the winner.

Mr. Cain also found videos by Natalie Wynn, a former academic philosopher who goes by the name ContraPoints. Ms. Wynn wore elaborate costumes and did drag-style performances in which she explained why Western culture wasn’t under attack from immigrants, or why race was a social construct.

Unlike most progressives Mr. Cain had seen take on the right, Mr. Bonnell and Ms. Wynn were funny and engaging. They spoke the native language of YouTube, and they didn’t get outraged by far-right ideas. Instead, they rolled their eyes at them, and made them seem shallow and unsophisticated.

“I noticed that right-wing people were taking these old-fashioned, knee-jerk, reactionary politics and packing them as edgy punk rock,” Ms. Wynn told me. “One of my goals was to take the excitement out of it.”

When Mr. Cain first saw these videos, he dismissed them as left-wing propaganda. But he watched more, and he started to wonder if people like Ms. Wynn had a point. Her videos persuasively used research and citations to rebut the right-wing talking points he had absorbed.

“I just kept watching more and more of that content, sympathizing and empathizing with her and also seeing that, wow, she really knows what she’s talking about,” Mr. Cain said.

Ms. Wynn and Mr. Bonnell are part of a new group of YouTubers who are trying to build a counterweight to YouTube’s far-right flank. This group calls itself BreadTube, a reference to the left-wing anarchist Peter Kropotkin’s 1892 book, “The Conquest of Bread.” It also includes people like Oliver Thorn, a British philosopher who hosts the channel PhilosophyTube, where he posts videos about topics like transphobia, racism and Marxist economics.

The core of BreadTube’s strategy is a kind of algorithmic hijacking. By talking about many of the same topics that far-right creators do — and, in some cases, by responding directly to their videos — left-wing YouTubers are able to get their videos recommended to the same audience.

“Natalie and Destiny made a bridge over to my side,” Mr. Cain said, “and it was interesting and compelling enough that I walked across it.”

BreadTube is still small. Ms. Wynn, the most prominent figure in the movement, has 615,000 subscribers, a small fraction of the audience drawn by the largest right-wing creators.

“Unfortunately the alt-right got a big head start on finding ways to appeal to white men,” said Emerican Johnson, a YouTuber who runs a left-wing channel called Non-Compete. “We’re late to the party. But I think we will build a narrative that will stand strong against that alt-right narrative.”

After the New Zealand shooting, Mr. Cain decided to try to help. He recently started his own YouTube channel — Faraday Speaks, a homage to the 19th-century scientist Michael Faraday — where he talks about politics and current events from a left-wing perspective. He wants to show young men a way out of the far right before more white nationalist violence ensues.

“You have to reach people on their level, and part of that is edgy humor, edgy memes,” he said. “You have to empathize with them, and then you have to give them the space to get all these ideas out of their head.”

Shortly after his first video was uploaded, Mr. Cain began receiving threats from alt-right trolls on 4Chan. One called him a traitor, and made a reference to hanging him. That was when he bought the gun. Several weeks ago, he moved out of West Virginia, and is working at a new job while he develops his YouTube channel.

What is most surprising about Mr. Cain’s new life, on the surface, is how similar it feels to his old one. He still watches dozens of YouTube videos every day and hangs on the words of his favorite creators. It is still difficult, at times, to tell where the YouTube algorithm stops and his personality begins.

Perhaps this shouldn’t be a surprise. Our political culture is now built largely on shapeshifting internet platforms, which have made flipping partisan allegiances as easy as changing hairstyles. It’s possible that vulnerable young men like Mr. Cain will drift away from radical groups as they grow up and find stability elsewhere. It’s also possible that this kind of whiplash polarization is here to stay as political factions gain and lose traction online.

Near the end of our interview, I told Mr. Cain that I found it odd that he had successfully climbed out of a right-wing YouTube rabbit hole, only to jump into a left-wing YouTube rabbit hole. I asked if he had considered cutting back on his video intake altogether, and rebuild some of his offline relationships.

He hesitated, and looked slightly confused. For all of its problems, he said, YouTube is still where political battles are fought and won. Leaving the platform would essentially mean abandoning the debate.

He conceded, though, that he needed to think critically about the videos he watched.