A conservative writer came to speak at the University of California at Berkeley on Thursday night. And — in a sign of how fraught and polarized college campuses across the country, and most particularly this college campus, have become — Berkeley braced for the worst.

Hours before Ben Shapiro’s speech, concrete barriers had been erected, nearby campus buildings had been shut down, and a secure perimeter had been established.

The City Council voted to allow police to use pepper spray during the kind of violent protests that have upended Berkeley this year.

Hundreds of people gathered inside the hall for the talk, and hundreds more protested, but the speech went ahead without disruption.

The Daily Californian, the student newspaper at UC-Berkeley, reported that the crowd outside grew to about a thousand people, and nine people were arrested by the Alameda County Sheriff’s Office and university police, but no one was injured by violence.

A group of students held a peaceful sit-in at a building that had been closed for the event, protesting being excluded from campus sites to make way for a conservative speaker.

Shapiro was invited by the Berkeley College Republicans with the Young America’s Foundation after high-profile cancellations last semester by controversial speakers that touched off a national debate about free speech, academic freedom and hate speech.

In February, 150 anti-fascist demonstrators sparked mayhem when they joined a large, peaceful protest against provocative writer Milo Yiannopoulos. They set fires, broke glass and threw rocks, prompting university police to shut the event down entirely. That set off a debate about whether only left-wing viewpoints could be heard on the state’s flagship campus, and whether other views had been smothered entirely.

The university, home to the free speech movement of the 1960s, is bracing for a larger, far more incendiary event later this month, with speakers including former White House chief strategist Stephen K. Bannon, Yiannopoulos and Ann Coulter during a “Free Speech Week.”

“I have a left-wing warm-up act, Ben Shapiro, before the real conservatives arrive,” Yiannopoulos said Thursday.

The Berkeley Patriot, a student group, invited Yiannopoulos and the others.

But a university official warned that school officials do not have crucial information they need to guarantee security for events planned for Sept. 24-27.

The Daily Californian, the student newspaper at Berkeley, reported that a group of faculty members had called for a boycott of classes while the “free speech” event was happening.

But as police took formation in riot gear on campus before Shapiro’s appearance, #BenAtBerkeley was trending on Twitter, as people across the country anticipated protests.

The event became a symbol. For some, it was another hateful provocation from the right.

For others, it was further proof that college campuses have become so liberal that even slightly different viewpoints trigger extreme responses.

To some it was a sorry statement about the state of the country at a polarized time.

And to many, it was an absurd spectacle.

When he spoke, Shapiro rejected the idea that Western politics are based on race, and said freedom, personal responsibility and separation of powers are the foundations. He rejected the “alt-right,” saying that “there’s a small group of absolutely terrible people that believe absolutely terrible things.”

While Shapiro took questions, and conversation took place at the event, protests continued outside, Berkeleyside reported.

But some objected to the strong police presence on campus.

After his speech, Shapiro fielded questions from supporters, opponents (he thanked the questioner for coming) and from a man identifying himself as Kyle Chapman — known as “Based Stickman,” who became a hero to some after a video of him breaking a wooden signpost over the head of a far-left protester at a Berkeley rally went viral. Chapman asked about racism directed at white people.

Shapiro rejected the idea that the only people who can be racist are white. He cautioned about identity politics.

He said affirmative action is racist because it judges people based on race, prompting a cheer from Chapman and his supporters.

Protesters were gathered outside, but they were peaceful. And after sometimes challenging but always polite questions, Shapiro thanked the audience. They gave him a standing ovation.