Srimad Valmiki Ramayana

पुरा स्वयंभुवे धीरः शिरांसि उपजहार यः ।
देव दानव गधर्व पिशाच पतग उरगैः ॥ ॥३-३२-१८॥
Purā svayaṃbhuve dhīraḥ śirāṃsi upajahāra yaḥ । Deva dānava gadharva piśāca pataga uragaiḥ ॥ ॥3-32-18॥
Translation
That resolute one who, in ancient times, offered his own heads to the Self-born Creator (Brahma); (and secured immunity from) gods, demons, Gandharvas, Pisachas, birds, and serpents.
हिंदी अनुवाद
उस धीर (दृढ़ निश्चयी) ने पूर्वकाल में ब्रह्मा जी (स्वयंभू) को अपने मस्तक काटकर अर्पित कर दिए थे; (जिसके फलस्वरूप उसे) देवता, दानव, गंधर्व, पिशाच, पक्षी और सर्पों से (अभय प्राप्त हुआ)।
English Commentary
This verse recounts the specific act of sacrifice that granted Ravana his boon. He is termed Dhirah (resolute/steadfast) for his horrific act of self-sacrifice—severing his own heads to offer to Lord Brahma (Svayambhu). In Hindu thought, the head represents the ego; offering it symbolizes total submission to the divine to achieve a goal. The verse lists the classes of beings he sought protection from: Devas, Danavas, Gandharvas, etc. This list is exhaustive regarding supernatural beings, setting the stage for the irony of his doom—he famously neglected to ask for protection from humans and monkeys, considering them too weak to be a threat.
हिंदी टीका
यह श्लोक रावण की तपस्या की पराकाष्ठा का वर्णन करता है। 'धीर' शब्द यहाँ उसके अदम्य साहस और संकल्प के लिए प्रयोग किया गया है। ब्रह्मा जी को प्रसन्न करने के लिए उसने प्रतीकात्मक रूप से अपने अहंकार और जीवन, अर्थात अपने 'शीश' काटकर हवन में चढा दिए। यह परम त्याग का परिचायक था। इस श्लोक का अंतिम चरण उस वरदान की भूमिका है जो उसे प्राप्त हुआ—उसे विभिन्न प्रकार के शक्तिशाली प्राणियों (देव, दानव, गंधर्व आदि) से न मारे जाने का अभय मिला। यह उसकी शक्ति की नींव है, जिस पर लंका का साम्राज्य खड़ा था।