Two students and a professor are in hospital after being stabbed during a class at the University of Waterloo on Wednesday afternoon.

Waterloo police said the stabbing occurred in a classroom at Hagey Hall at around 3:30 p.m.

The three victims suffered non-life-threatening injuries, Supt. Shaena Morris said.

A male suspect, who she said was a member of the university community, was arrested at the scene with the assistance of university security officials. Morris would not elaborate on how the suspect is connected to the school.

When asked about a possible motive, Morris said it is too early in the investigation to determine the reason behind the attack.

"This incident is contained entirely within the university community itself. There's no further threat to public safety, either on campus or outside in the broader community at this time," she said.

Nick Manning, associate vice president of communications for the University of Waterloo, confirmed that the victims are two students and a professor.

He added that the stabbing occurred during a second-year philosophy class.

"This is a terrible incident for anybody in the class that was affected," Manning said, adding that the university is providing resources to all who had been impacted by the incident.

"The entire community is really concerned."

The university said it is supporting the police investigation. It cancelled all Wednesday evening classes in Hagey Hall, which will remain closed until Thursday morning.

Students who were in the classroom recalled what had happened. Yusuk Kaymak said a guy walked in and asked the teacher if he was the professor, who answered yes.

The guy then pulled out a knife, "and after that, everybody just ran out," Kaymak said.

"After we went outside, there was a kid that was stabbed. He was bleeding [from] his arm. I don't know what happened to the professor."

Another student, Jimmy Li, said the guy pulled two big knives from his backpack and attacked the professor.

Mayor Dorothy McCabe called the incident "troubling" and "disturbing."

"I'm relieved that the individual involved was quickly apprehended. Waterloo City Council & staff offer our support & hopes for a full recovery to those injured on UW's campus today," McCabe tweeted.

- with files from CTV News Kitchener