Once upon a time King Chitrabhanu of the Ikshvaku dynasty, who ruled over the whole of Jambudvipa (India), was observing a fast with his wife, it being the day of Maha Shivaratri. The sage Ashtavakra came on a visit to the court of the king.
The sage asked the king the purpose of his observing the fast. King Chitrabhanu explained that he had a gift of remembering the incidents of his past birth, and in his previous life he had been a hunter in Varanasi and his name was Suswara. His only livelihood was to kill and sell birds and animals. The day before the new moon, while roaming through forests in search of animals, he saw a deer, but before his arrow flew he noticed the deer's family and the their sadness at its impending death. So he let it live. He had still not caught anything when he was overtaken by nightfall and climbed a tree for shelter. It happened to be a Bael tree. His canteen leaked water, so he was both hungry and thirsty. These two torments kept him awake throughout the night, thinking of his poor wife and children who were starving and anxiously waiting for his return. To pass away the time he engaged himself in plucking the Bael leaves and dropping them down onto the ground.
The next day he returned home and bought some food for himself and his family. The moment he was about to break his fast a stranger came to him, begging for food. He served the food first to stranger and then had his own.
At the time of his death, he saw two messengers of Lord Shiva, sent to conduct his soul to the abode of Lord Shiva. He learnt then for the first time of the great merit he had earned by unconscious worship of Lord Shiva during the night of Shivaratri. The messengers told him that there had been a Lingam (a symbol for the worship of Shiva) at the bottom of the tree. The leaves he dropped had fallen on the Lingam, in imitation of its ritual worship. The water from his leaky canteen had washed the Lingam (also a ritual action), and he had fasted all day and all night. Thus, he unconsciously had worshiped the Lord. At the conclusion of the tale the King said that he had lived in the abode of the Lord and enjoyed divine bliss for a long time before being reborn as Chitrabhanu.
This story is narrated in the Garuda Purana