​A crowd protesting a far-right commentator's appearance at the University of California at Berkeley hurled smoke bombs, broke windows and sparked a massive bonfire, prompting officials to call off the event.

The decision came two hours before Wednesday's talk by Milo Yiannopoulos, a polarizing editor of Breitbart News, after some 1,500 people had gathered outside the venue.

But officials said it was a smaller group of protesters dressed in black and in hooded sweatshirts that showed up as night fell to break windows, throw smoke bombs and flares, and start the raging blaze outside the building.

"This was a group of agitators who were masked up, throwing rocks, commercial grade fireworks and Molotov cocktails at officers," said UC Berkeley Police Chief Margo Bennet.

Bennet said police determined they couldn't guarantee security, cancelled the event and evacuated Yiannopoulos from the building.

There were no immediate reports of arrests or serious injuries, she said.

U.S. President Donald Trump threatened to revoke federal funding from the university early Thursday, suggesting, in a tweet, that the school itself was stifling free speech. Former Breitbart CEO Steve Bannon was instrumental in rallying support for Trump during the election campaign and is now the president's chief strategist.

Banned from Twitter

Prior to the burst of violence, hundreds of peaceful demonstrators carrying signs that read "Hate Speech Is Not Free Speech" had been protesting the appearance for hours.

As the evening wore on, crowds of protesters cleared away from outside the building. By 8 p.m. local time the crowd had thinned and at least 100 protesters that remained danced to a brass band playing music and marched off campus and into a main avenue.

Yiannopoulos, a 32-year-old right-wing provocateur, is a vocal supporter of Trump and a self-proclaimed internet troll whose comments have been criticized as racist, misogynist, anti-Muslim and white supremacist. He is a provocateur who helped give a voice to the alt-right movement, which rejects mainstream conservatism and promotes white supremacy and whose supporters helped propel Trump to power.

Yiannopoulos was banned from Twitter after leading a harassment campaign against Ghostbusters actress Leslie Jones.

Free Speech or Hate Speech

Milo Yiannopoulos, seen here during a Jan. 25 appearance at the University of Colorado, was evacuated from the University of California at Berkeley amid Wednesday night's protests. (Jeremy Papasso/Daily Camera/Associated Press)

His visit to Berkeley was sponsored by the campus Republican club. The university has stressed it did not invite him and does not endorse his ideas but is committed to free speech and rejected calls to cancel the event.

"We are proud of our history and legacy as the home of the Free Speech Movement," Dan Mogulof, Berkeley's assistant vice chancellor, said in a statement released Thursday.

"While we have made clear our belief that the inflaming rhetoric and provocations of Mr. Yiannopoulos were in marked opposition to the basic values of the university, we respected his right to come to campus and speak once he was invited to do so by a legitimate student group."

Yiannopoulos posted a message on his Facebook page after the event was cancelled. "I'll let you know more when the facts become clear. One thing we do know for sure: the Left is absolutely terrified of free speech and will do literally anything to shut it down."

The Berkeley College Republicans said its "constitutional right to free speech was silenced by criminals and thugs."

"Their success is a defeat for civilized society and the free exchange of ideas on college campuses across America," it said in a statement.

CALIFORNIA-UCBERKELEY/PROTESTS

Police officers prepare to deploy a skirmish line after a student protest turned violent on Wednesday night. There were no immediate reports of arrests or serious injuries. (Stephen Lam/Reuters)

The university, which had requested assistance from police in nine UC campuses, sent a notice to all students earlier Wednesday that warned of crowds near the student union, where the 500-seat, sold-out event was scheduled.

Past appearances by Yiannopoulos have sparked protests, shouting matches and occasional violence at stops around the country. A man was shot and wounded at protests outside his Jan. 21 talk at the University of Washington in Seattle.

Rowdy protests at UC Davis Jan. 13 prompted campus Republicans to cancel his appearance at the last minute. His final stop was supposed to be UCLA on Thursday, but the invitation was rescinded. 

CALIFORNIA-UCBERKELEY/PROTESTS

A man removes graffiti at a bank machine after Wednesday night's student protest turned violent. Demonstrators hurled smoke bombs, broke windows and sparked a massive bonfire. (Stephen Lam/Reuters)

With files from CBC News