楞嚴經
The mantra was, according to the opening chapter of the "Śūraṅgama Sūtra", historically transmitted by Gautama Buddha to Manjushri to protect Ananda before he had become an arhat. It was again spoken by the Buddha before an assembly of monastic and lay adherents.