BERKELEY — A marathon standoff ended peacefully with the release of scores of protesters who occupied Wheeler Hall on the UC Berkeley campus for more than 12 hours Friday.

The protesters, who barricaded themselves in a second-story classroom, were cited for misdemeanor trespassing and released in small groups beginning about 7:30 p.m. Afterward, police stood guard outside the building into the night.

The sound of demonstrators chanting “This is what democracy looks like” filled the air as police led the protesters out. They then joined the massive crowds that had gathered around Wheeler Hall throughout the day.

One of the released protesters, a woman who did not give her name, said she was surprised at the size of the crowd. “I knew there were people outside, but I didn’t realize there were so many,” she said.

The protest against increased student fees began about 7:30 a.m., with those inside using a bullhorn to yell at demonstrators gathered outside, accusing police of “coming in swinging” and using pepper spray. The demonstrators had hung a sign out a window that read “32 Percent Hike, 900 layoffs,” with the word “Class” crossed out in red.

Outside the building, dozens of supporters gathered throughout the day as word of the protest spread — including online via Twitter posts supposedly from protesters inside the building. Supporters brought food and water to be tossed up to the demonstrators throughout the afternoon.

The students originally bolted themselves inside Wheeler Hall but were forced to flee upstairs when authorities forced their way in and occupied the building except for the second-floor classroom where the protesters had gathered.

Three students were separated from the larger group and arrested, said UC police Capt. Margo Bennett. Aakash Desai, one of the arrested students, later said he and the other two arrested were charged with felony burglary. All three were released about 5:30 p.m., he said.

Bennett refuted claims that officers had used unnecessary force on the protesters. But police presence was heavy. The Alameda County Sheriff’s Office sent in deputies to back up the UC and Berkeley police, whose officers were dressed in riot gear and carried batons and rubber bullet rifles. An officer was taken to the hospital early Friday, but it was not known what the extent or causes of the injuries were.

As the day wore on, tempers flared between demonstrators and officers. A Berkeley police officer hit a young woman in the face between her eyebrows with his baton during a scuffle on the northeast side of Wheeler Hall. Organizers struggled to keep the situation calm by telling the angry protesters to sit down and not to provoke the officers.

About 3,800 students were affected as classes were canceled at Wheeler, which houses the English Department. Several other campus buildings were shut down as a routine precaution, university officials said. Activities in other campus buildings were disrupted by falsely activating fire alarms, officials added.

Crowds cheered wildly as activists reiterated Friday night the demands that led to the occupation of the building. Among other demands, they called for a repeal of the 32 percent fee hike, the reinstatement of fired custodians and for the firing of the UC President Mark Yudof, who students blamed for the circumstances leading to the protest.

Elsewhere, protesters who on Thursday took over Kerr Hall, the home of UC Santa Cruz administration, continued to demonstrate Friday.

The campus closed Kerr Hall because of safety concerns, and students were also occupying Kresge Town Hall. Students reportedly stayed overnight in both locations. No arrests have been reported, though administrators are considering other punishment.

Several hundred students and faculty rallied for an hour outside Kerr Hall beginning at noon Friday. “We need to keep mobilizing and keep coming out here,” graduate student Mark Paschal yelled into a bullhorn. “It’s the only way — if we join together.”

Thirty to 50 protesters staged a takeover of Campbell Hall at UCLA on Thursday, as regents met across campus to approve the fee hike. More than 50 students were arrested Thursday during protests at UC Davis.

Staff writers Doug Oakley and Kristin Bender, the Santa Cruz Sentinel and The Associated Press contributed to this story.