A suspect stabbed four people on a university campus in central California Wednesday morning before police shot and killed him, authorities said Wednesday.

Two of the victims attacked at the University of California, Merced, were taken by helicopter to hospitals for treatment, spokeswoman Lorena Anderson said. The two other victims were treated locally, she said.

Campus officials said the victims were two students, a staff member, and a vendor. They added that the assailant was a student but had not confirmed his identity or provided a motive for the attack. 

Officials added that they were still working out a timeline of events leading up to the stabbings, and it wasn't clear how the attack played out.

Student Alex Lopez was heading to his class, when he realized something was wrong on campus.

"I was listening to a podcast, and there was a break in talking, and I just hear a gunshot," he said.

He said police and first responders flooded the scene.

"You see this stuff all over the news and stuff and you see it happen to all these other schools," but you don't expect it to happen at your school, said Lopez, 21.

Few details about the stabbing were immediately available, but the incident occurred at around 8 a.m. local time in the Classroom and Office Building, KCRA.com reported. The suspect was reportedly apprehended.

The rural school is about 120 miles south of Sacramento. The campus in the city of Merced opened a decade ago -- the first new school built in the University of California system since 1965, the university says on its website.

The Associated Press contributed to this report