Lord Shiva was so deeply attached to Uma that for 1000 years, he was possessed by only her thoughts. He forgot about his duties and as a result, there was anarchy all over the world. His obsession with Uma had also decreased his radiance. He decided to do penance with the objective of regaining his radiance.
When Uma came to know about his decision, she was unhappy but Lord Shiva consoled her by relating the significance of his decision. Before leaving, he entrusted the responsibility of her security to Nandi. He started wandering in search of a suitable place for doing penance. Sometimes, he did penance under the tree, sometimes on the mountain peaks and sometimes on the banks of a river. Initially, he used to eat only kand and Moola but later on he stopped eating even that and lived only on air. This way, 900 years passed during which he travelled to all the three lokas.