A UCLA police officer shocked a student with a stun gun at a campus library after he refused repeated requests to show student identification and wouldn't leave, police said.

The student, Mostafa Tabatabainejad, was shocked Tuesday at about 11 p.m. as police did a routine check of student IDs at the University of California, Los Angeles Powell Library computer lab.

"This is a long-standing library policy to ensure the safety of students during the late-night hours," said UCLA Police Department spokeswoman Nancy Greenstein.

She said police tried to escort Tabatabainejad, 23, out of the library after he refused to provide identification. Tabatabainejad instead encouraged others at the library to join his resistance, and when a crowd began to gather, police used the stun gun on him, Greenstein said.

Tabatabainejad was arrested for resisting and obstructing a police officer and later released on his own recognizance. He declined to comment Wednesday night.

The incident was recorded on another student's camera phone and showed Tabatabainejad screaming while on the floor of the computer lab. It was the third incident in a month in which police behavior in the city was criticized after amateur video surfaced. The other two involved the Los Angeles Police Department.

Acting Chancellor Norman Abrams promised an investigation.

"The safety of our campus community is of paramount importance to me," Abrams said in a statement.