Once all the Buddhas met on the summit of the mountain Meru to discuss how they could protect human beings from the Hala Hala poison of the evil demons. They collected the water of life [amrita, Tibetan: dü tsi. from the depths of the ocean and gave it to Vajrapani keep until it should be shared out among menkind. But the the chief of the evil spirits Lha Mayin Rahul heard about it, and when Vajrap was absent, he drunk all the amrita. Not content with that, he then urinated into the empty vessel.
After this evil deed he ran far away. He had already gone far a when Vajrapani returned home. As soon as he discovered the theft he set off in pursuit of the evil-doer. At last he caught up with him and threw his vajra at him destroying the lower part of Rahul's body, but because Rahul had drunk the amrita he managed to survive his terrible injuries. The water of life dripped onto the earth out of all his wounds and wherever it fell all kinds of medicinal herbs sprang up.
Once again the Buddhas met to discuss what to do with Rahul's urine. Simply to pour it away would have entailed a dreadful danger to all living creatures because it contained a large amount of the Hala Hala poison. They decided that Vajrapani should be made to drink the urine as a punishment for his carelessness. The poison changed the color of his body from yellow to dark blue.
Rahul too was punished. The Buddhas changed his legs into a dragon's tail and transformed his wounds into a great gullet and several eyes.
Even when young Rahul had already been a real monster, but after this transformation he became much worse. Because the sun and the moon had betrayed him when he was fleeing from Vajrapani they became the objects of his particular vengeance. He cast his shadow over them, attempting to swallow them, and thus he continues to cause eclipses of both the sun and the moon.
Source: E. Schlagintweit, Buddhism in Tibet, pp. 114 ff