TORONTO -- A 23-year-old man accused of dumping buckets of fecal matter on people was released on bail Wednesday after spending three weeks behind bars.

Investigators previously said an unknown male walked into the University of Toronto’s Robarts Library on Nov. 22 and dumped a bucket of “liquefied fecal matter” on two students seated at a table.

Two similar incidents were later reported at the Scott Library at York University’s Keele campus on Nov. 24 and outside a U of T building near College Street and University Avenue one day later.

In total, police said five people were assaulted.

The case and the ensuing manhunt gripped the city, with students and members of the larger community expressing shock and disgust over the disturbing incidents, including Mayor John Tory, who called the behaviour “inexplicable.”

In an effort to identify the man responsible, investigators released security camera images of a possible suspect.

On Nov. 26, police confirmed that after receiving a number of tips, an arrest had been made in the case.

Police said Toronto resident Samuel Opoku was arrested at a shelter in the area of Queen Street West and Spadina Avenue.

Opoku’s lawyer, Jordan Weisz, previously said questions about his client’s mental state would play a role in proceedings.

A justice of the peace ordered Opoku to maintain regular visits to his doctor, continue to take medication and seek formal counselling.

"The courts and the crowns and the defence counsel all worked together in a very sober and reflective and careful and considerate way to put together these plans," Weisz told reporters on Wednesday.

"We've returned to bail court multiple times and we put together a plan that we felt was satisfactory and we were very glad and relieved that the judge agreed with us today."

He is scheduled to reappear before a judge at Old City Hall court on Dec. 23.