The University of California, Berkeley spent almost $4 million on security for a month of free speech events last year when the famously liberal campus became a flashpoint for the country's political divisions.

The university revealed in documents that it spent $3.9 million to bring in outside police forces, pay their room, board and overtime, have ambulances on standby, rent barricades and pay other security costs for three events scheduled from Aug. 27 to Sept. 27.

The university split the costs with the office of UC President Janet Napolitano, who oversees the 10 UC campuses, for what both described as unprecedented security circumstances.

The figure was first reported Sunday by The Daily Californian after UC Berkeley Chancellor Carol Christ referenced the cost in a speech.

"We would have certainly preferred to expend these precious resources on our academic mission," Christ said Monday in a statement from the university.

But she said the university does not regret having taken steps to ensure "free speech and the safety of our campus community."

Several news organizations, including The Associated Press, requested a tally of the costs last year but the university has been unresponsive. Christ mentioned the total cost in a speech last week, prompting the newspaper to make the request anew.

UC Berkeley's reputation as a liberal bastion and the birthplace of the 1960s Free Speech Movement made its campus and the city of Berkeley a rallying point for extremist groups from the left- and right-wing after President Donald Trump's election.

Several political demonstrations turned violent, starting with a February 2017 event that was to be hosted by rightwing firebrand Milo Yiannopoulos. It was ultimately canceled as rioters set fires and smashed campus windows ahead of his planned speech.

After those riots, the university ramped up security for other politically charged events.

UC Berkeley spent $190,404 on security costs for an Aug. 27 counter protest billed as the "Rally Against Hate" called to oppose a smaller gathering of right-wing protesters on Aug. 27 in a Berkeley park. Black-clad anarchists stormed the largely peaceful rally and attacked at least five people.

Security costs related to a Sept. 14 appearance by conservative speaker Ben Shapiro cost $836,421. Unprecedented security measures included putting the campus on a virtual lockdown by sealing off campus buildings and nearby parking lots, which critics called overkill but the university defended as effective since no one got hurt.

The priciest event was a Sept. 24-27 event called "Free Speech Week," organized by Yiannopoulos who said he planned to return to UC Berkeley with a lineup of high-profile conservatives. Ultimately the event was canceled but the university spent nearly $2.9 million on security.

The bulk of those costs paid for law enforcement back up called in from other UC campuses and state and regional law enforcement agencies, said UC Berkeley spokesman Dan Mogulof.