The collapse of the mosque’s minaret—already facing limited resources—nearly resulted in a major catastrophe.