The dean of the university's Faculty of Law, professor Jessica Palmer, apologised to students in an email the next day.
The Legal Ethics exam included "a hypothetical scenario that had strong similarities to the recent Christchurch tragedy", she said.
"While we endeavour to include real-world scenarios in our courses and examinations, given these recent events Question 41 was clearly inappropriate.
"I acknowledge that some of you will have been upset by the question and that this may have also led to added anxiety during the examination."
Palmer said students "feeling ongoing distress" or who thought their exam performance was affected by the question should contact her to discuss it further.
She also directed students to seek help from support services if needed.
"At this time, we are reminded that how the mosque attacks have affected each of us will differ," she said.
Palmer also sent an apology on behalf of the lecturer who set the exam question.
"My intent was to come up with a situation where the cab rank rule would impose a truly horrific burden on a lawyer, leading to a discussion about good cause and whether the rule should be retained," the examiner said.
"I should have realised that the scenario I presented was likely to cause distress, and I am deeply sorry."
The University of Otago said its Faculty of Law leadership team had moved quickly to deal with the fallout from the exam question.
The university's students attracted headlines early last year when a camp for second-year law students came under scrutiny amid claims it typically involved excessive drinking, inappropriate behaviour by students and nudity.
The camp was run by the Society of Otago University Law Students (Souls).
An independent review - conducted by David Sims, of Downie Steward Lawyers - released in December found the law camp had been a "deeply disturbing and unpleasant" experience for some students.
Sims did not find any evidence of criminal behaviour or sexual misconduct but said drunkenness and sexualised behaviour was "commonplace".
A sanitised version of the camp had been planned for this year with strict new rules around nudity and drinking.
The cab rank rule obliges a barrister to accept any work they are available for and competent to do.
The original purpose of the rule was to ensure that unpopular parties could get representation and that barristers were not criticised for acting for them, the NZ Law Society said.