The London School of Economics (LSE) has apologised to two students who were forced to cover up T-shirts depicting a cartoon of Jesus and the prophet Muhammad.

Christian Moos and Abhishek Phadnis were representing the students' union Atheist, Secularist and Humanist Society (ASH) at the university's freshers fair in October, when they were told that displaying a depiction of Muhammad, prohibited under Islamic law, may constitute harassment of a religious group.

After security staff threatened them with expulsion from the fair, the two students agreed to cover up the T-shirts.

The students then submitted a formal complaint, which has prompted LSE to issue an apology from its director, Prof Craig Calhoun, acknowledging that, "with hindsight, the wearing of the T-shirts on this occasion did not amount to harassment or contravene the law or LSE policies".

Calhoun explained: "Members of staff acted in good faith and sought to manage the competing interests of complainant students and yourselves in a way that they considered to be in the best interests of all parties on the days in question."

LSE's pro-director for teaching and learning, Prof Paul Kelly, told BBC Radio 4's Today programme that the university was attempting to balance the rights of all students involved in a dispute, but accepted that it "got the judgment wrong".

Kelly said: "In general, our attitude is very tough in promoting free speech at public events, lectures and student societies.

"This was a complex event because it's a welcome event. It's when students from 130 countries arrive in the UK all together. Freedom of speech still applies there, but it wasn't the same as us objecting to a student society event or a public lecture, or if Christian – as he later did – hosted an event where students wore the T-shirt. "

He added: "The LSE has a proud and continuing tradition of promoting free speech and debate within the law.

"The law in this case was complex and given the complaint that Christian and Abhishek put forward with the backing of solicitors looking for judicial review, we had to take legal advice. It was always a grey area."

But Moos said he had received only positive responses to the T-shirt on the day and had never been shown any evidence of complaints being made.

He said: "I think this was a very straightforward decision. It was simply two students exercising their right to freedom of expression that they have as much as any other student who might wear religious symbols or T-shirts expressing their faith.

"We've always said we support freedom of expression within the law. If somebody is wearing a racist or violent or gory T-shirt, that would be a totally different situation. But [it's different] when you are wearing an innocuous T-shirt that does not offend or harass anyone, not even by the most stringent standards."