Mahashivaratri is a festival in which devotees worship Lord Shiva all night. It is a popular custom to fast all night. Only after fasting all night devotees eat the Prasad offered to Lord Shiva. There are two different versions of this festival which leads to an all night worship of Lord Shiva.
The first one is known as “The Legend of Ludbhaka”. This is a legend of a man known as Ludbhaka, who was a poor tribal man and a devout worship of Lord Shiva. Once when he went into the deep forest to collect firewood and as the night fell he lost his way. The jungle was full of wild animals whom voices he could hear. Scared out of his wits, Ludbhaka climbed a tree which happened to be a bael tree. He climbed on to a branch and waited for dawn. Being afraid to sleep which carried the risk of falling down, he started plucking the leaves on the branch chanting Lord Shiva’s name. When the sun came up he noticed that there was a Shiva Lingam below the tree on which he spread leaves unnoticing. He had worshipped and kept a fast all night in the name of Lord Shiva. After that day the story of Ludbhaka has been recited every year on the night of Mahashivaratri.
The other version of this legend is known as the “Story of King Chitrabhanu”. This legend is engraved in the Shanti Parva of the Mahabharata. The story is recited by Bhishma on his death bed of arrows. It says that there was a king known as the King Chitrabhanu of the Ikshvaku dynasty who ruled over the whole of Jambudvipa. On Mahashivaratri he was observing the fast with his wife when sage Ashtavakra visited the court of king. He asked for the reason for observing the fast. King Chitrabhanu who had the gift of remembering the incidents from his past life said that he was a hunter in Varanasi in his past birth. His name was Suswarna. He lived on killing and selling birds and animals. One day when was out for hunt, night approached quickly. To protect himself from wild animals he climbed a tree which happened to be a bael tree. He had hunted a deer that day which he tied it to the branch of the tree. He waited for dawn while thinking about his poor and hungry family waiting for his return and wept. His own hunger and thirst kept him awake all night so to past the time he plucked leaves from the tree. The next morning he sold the deer and returned home with food. While he was about to have his food a beggar came by his door. Suswarna fed the beggar first and then ate his food. It is said that, on that night of darkness there was a Lingam below the tree. Suswarna has observed fast all night and worshipped Lord Shiva without knowing. At the time of his dead two messengers came to adobe his soul and only then he noticed his deed. After long ages of divine bliss he was reborn as King Chitrabhanu.