Initially, Lord Brahma had 5 heads. But then, once, Lord Brahma was doing Veda Paaraayana. At that time, the fifth head, due to Srihari’s will only was doing the Veda Paaraayana in apasvara, or wrongly. Hearing this, Lord Shiva was angry, and he cut off the fifth head of Lord Brahma. But now, Lord Shiva incurred a Brahma Hatya Dosha because of that. And because of that, Lord Brahma’s head was stuck in Lord Shiva’s hand.
He tried to remove the head of Lord Brahma from His hand, but it wasn’t coming off. He tried a lot to remove His Brahma Hatya Dosha. He went in the 10 directions and preached the mahima of Srihari’s naama and its role in removing sins. He went to Yamuna, but the Yamuna water was dried up. He even went to Plakshadvipa, but it was invisible to Him. After that, Lord Shiva went to Pushkara Kshetra, and there too Pushkara refused to remove the Brahma Hatya Dosha.
He went to Alakananda-Ganga Sangama and dipped His hand in the water, and Brahma’s fifth head was detached from His hands. Even today, at this place, there is a place named Brahma Kapaala. Therefore, finally He went to Kurukshetra, where He saw Lord Vishnu in the form of Keshava. (Keshava roopa is one of the 24 forms of Lord Vishnu. For simple visualization of Lord Keshava, just bring Lord Vishnu in front of you. Swap the Shankha and Chakra positions; that is Keshava roopa of Lord Vishnu).
Then, Lord Mahadeva, on seeing Lord Keshava, was overjoyed and praised Him. Lord Keshava was pleased by Lord Mahadeva’s devotion and removed the Brahma Hatya Dosha. Even the Matsya Purana narrates a story about why Lord Shankara removed the fifth head of Lord Brahma. Once, when Lord Brahma had created Shataroopa Devi, He was attracted towards her. On seeing this, Lord Shiva was angry and cut off Brahma’s head and incurred Brahma Hatya Dosha.
But does this indicate that Lord Shiva is greater than Lord Brahma? No. As per SrimadBhagavatam, Lord Shiva was born from Lord Brahma’s forehead, and hence He is the son of Lord Brahma. This all happened because of Srihari’s will. Lord Shiva made Lord Brahma into Chaturmukha. And this is also one of the reasons why Lord Rama installed the Shivalinga, to remove the Brahma Hatya dosha of Lord Shiva.
Lord Rama hadn’t incurred any Brahma Hatya Dosha by killing Raavana. Because Ravana was a rakshasa. When a child is born, he/she gets the Maatrujaati. Ravana’s mother, Kaikasi, is a Rakshasi, though Ravana is the son of Sage Vishravas, who is a Brahmin. So, Ravana gets the Maatrujaati and hence is a rakshasa. So, he isn’t a Brahmin. And he was a lustful demon who lusted after women, which is the opposite of what Brahmins should do. Therefore, he wasn’t a Brahmin. And hence, Lord Ramachandra didn’t incur any Brahma Hatya Dosha for killing Ravana.
But did Lord Ramachandra install the Shivalinga after killing Ravana? So, the answer is no. Rama didn’t install the Shivalinga after killing Ravana, but before. Rama is Narayana, and even the Vedas say:
निष्कलङ्को निरञ्जनो निर्विकल्पो निराख्यातः शुद्धो देव एको नारायणः। न द्वितीयोऽस्ति कश्चित्॥
The one Supreme Lord is Narayana—completely flawless, untainted by material bonds, unchanging, indescribable, and eternally pure. There is absolutely no second to Him.
[Narayana Upanishad]
And Lord Rama is Lord Narayana Himself, and hence cannot incur any kind of Dosha. Krishna Himself says that He doesn’t have Karma Phala lepa. Lord Rama, being the Parabrahman, doesn’t need to worship Lord Shiva at all. It is because Lord Vishnu, in the Padma Purana, said,
अहमप्यवतारेषु त्वां च रुद्र महाबल ।
तामसानां मोहनार्थं पूजयामि युगे युगे ॥ ३५ ॥
O Rudra of immense strength! In My various incarnations, I too will offer worship to you, age after age, solely for the purpose of deluding those of a Tamasic disposition.
[Padma Purana, Uttara Khanda, Adhyaaya 235, Shloka 35]
अन्यं देहि वरं देव प्रसिद्धं सर्वजन्तुषु ।
मूर्तो भूत्वा भवानेव मामाराधय केशव ॥ ४२ ॥
मां वहस्व च देवेश वरं मत्तो गृहाण च ।
येनाहं सर्वदेवानां पूज्यात् पूज्यतरो भवे ॥ ४३ ॥
देवकार्यावतारेषु मानुषत्वमुपागतः ।
त्वामेवाराधयिष्यामि त्वं च मे वरदो भव ॥ ४४ ॥
(Lord Shiva says to Lord Vishnu): "O Lord, grant me another boon that will be famous among all living beings. O Keshava, assuming a manifest physical form, you yourself must worship me! Carry me as well, O Lord of the gods, and accept a boon from me—by which I may become even more worthy of honor than all other worshiped gods."
(Lord Vishnu replies): "Whenever I descend into human forms during my incarnations for the tasks of the gods, I will worship you alone, and you shall be the bestower of boons unto me."
[Varaha Purana, Adhyaaya 73, Rudra Geeta, Shlokas 42–44]
And this statement from the Kurma Purana is sufficient to say that the installation of Lord Shiva, before Lord Rama killed Ravana, was just the fulfillment of the boon provided by Him as Lord Vishnu, to Lord Shankara.
सेतुमध्ये महादेवमीशानं कृत्तिवाससम् ।
स्थापयामास लिङ्गं तत् पूजयामास राघवः ॥
तस्य देवो महादेवः स्थावरं वरमुत्तमम् ।
In the middle of the bridge, Mahadeva, Eeshaana, clad in (elephant) skin, was established as a linga that was worshiped by Raghava.
[Kurma Purana]
Thus, it wasn’t Lord Rama who incurred the Brahmahatya dosha. Rather, Lord Rama installed the Shivalinga to fulfill the boon given to Lord Shiva. But then, Lord Rama even did that to remove the Brahmahatya dosha that Lord Shiva had incurred by cutting Brahma’s 5th head. So, when Lord Rama installed the Shivalinga, it was facing towards the Rama Setu. The Shaastras say that doing darshan of Rama Setu removes even higher aparadhas like Brahma Hatya dosha because it is the setu where Lord Rama walked. So, by installing the Shivalinga, Lord Rama removed the Brahma Hatya dosha of Lord Shiva.
So, this was the reason why Lord Shiva cut the head of Lord Brahma and how He got freed from that dosha by the blessings of Lord Keshava/Lord Rama.
NOTE: Here, Lord Shiva incurring Brahma Hatya Dosha is a very rare incident. Because He is a devata shreshtha and Mahadeva, and is the Parama Bhakta of Lord Vishnu, He doesn’t perform any ill acts. But very rarely this happens with the devatas. Lord Shiva is the Jagadguru and is infinitely greater than Indra and other devatas. If that’s the case, we aren’t even a speck in front of Him.
When listing these incidents, some people tend to mock Lord Shiva, saying it was He who incurred Brahma Hatya dosha, but they must keep in mind how great Mahadeva is, because insulting Mahadeva is a great sin. Insulting Lord Shankara is not acceptable to Lord Vishnu, and insulting Lord Vishnu is not acceptable to Mahadeva, because Mahadeva is a Bhakta of Lord Vishnu; so a Bhakta cannot tolerate the insult of Bhagavan, and Bhagavan can’t tolerate the insult of a Bhakta.
Hope this helps!
Jay SriRam!
ShriShiva Antargata ShriBhaaratiRamana Mukhyaprana Antargata ShriJayaa Sankarshana Abhinna ShriLakshmiNarasimha Abhinna ShriKrishnarpanamastu!