A university has apologised to two students who were forced to cover up T-shirts depicting a cartoon of the prophet Mohammed and Jesus Christ.

Christian Moos and Abhishek Phadnis were wearing the garments at the London School of Economics (LSE) freshers' fair, as representatives of the students' union Atheist, Secularist and Humanist Society, in October when they were told that displaying a depiction of Mohammed, prohibited under Islamic law, may constitute harassment of a religious group.

With security staff threatening them with expulsion from the fair, the two students reluctantly agreed to cover up the T-shirts.

After the students launched a formal complaint, the LSE issued a statement saying its director Professor Craig Calhoun had apologised and acknowledged that, "with hindsight, the wearing of the T-shirts on this occasion did not amount to harassment or contravene the law or LSE policies".

Prof Calhoun told the pair: "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 pro-director Professor Paul Kelly told BBC Radio 4's Today programme that the university was attempting to balance the rights of different students involved in a dispute, but accepted that it "got the judgment wrong".

Prof 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. That's fine."

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. Yes, I got the judgment wrong, but it was a complex decision.

"Freedom of speech in the UK is constituted under the rule of law. The rule of law in this case comprises the Human Rights Act, the 2010 Equality Act, the 1986 Universities Extension Act. All of these things come together in judging disputes between students. Each one of those laws is perhaps clear, but when they all come together we have to make judgments.

"Those judgments are the sort of things that lawyers test in court, so it isn't quite clear. This isn't a First Amendment culture where you have a simple constitutional right to free speech without qualification."

But Mr Moos said that 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. It is extremely shocking that LSE try to justify their decision.

"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."