A camera phone captured a University of California, Los Angeles student being shot with a stun gun by a police officer after he allegedly refused repeated requests to show his student identification and would not leave a campus library, university police said Wednesday.

The incident occurred about 11 p.m. Tuesday after police did a routine check of student identification at the 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 Mostafa Tabatabainejad, 23, out of the library after he refused to provide ID and would not leave.

Tabatabainejad, who was arrested for resisting and obstructing a police officer, was later released on his own recognizance.

"As the officers attempted to escort him out, he went limp and continued to refuse to cooperate with officers or leave the building," Greenstein said. He encouraged others at the library to join his resistance, police said. When a crowd began to gather they used the stun gun on him.

The arrest was captured on another student's camera phone and showed Tabatabainejad screaming while on the floor of the computer lab. The video also showed the student shouting, "Here's your Patriot Act, here's your ... abuse of power," according to the campus newspaper, the Daily Bruin.

Congress passed the Patriot Act laws after the attacks of Sept. 11, 2001 with the goal of making fighting terrorism easier, but critics say the laws intrude on civil rights.

There is no phone listing for Tabatabainejad and neither he nor his attorney could be located for comment.