The Bodhisatta once took service under Suciparivāra of Benares, in whose household everyone kept the fast on uposatha-days. The Bodhisatta, not knowing this, went to work as usual on the fast day, but, on discovering that no one else was working and the reason for their abstention, he refused to take any food, and as a result of his fasting died in the night. He was reborn as son of the king of Benares, and later became king under the name of Udaya. On meeting Addhamāsaka (q.v.), Udaya shared the kingdom with him, but one day Addhamāsaka, discovering that he harboured a desire to kill Udaya, renounced his kingdom and became an ascetic. When Udaya heard of this he uttered a stanza, referring to his own past life, but no one could understand the meaning of it. The queen, anxious to learn the meaning, told the king's barber Gangamāla how he might win the king's favour, and when the king offered him a boon, Gangamāla chose to have the stanza explained to him. When he learnt how Udaya had won a kingdom as a result of having kept the fast for half a day, Gangamāla renounced the world and, developing asceticism, became a Pacceka Buddha. Later he visited King Udaya and preached to him and his retinue, addressing the king by name. The queen-mother took offence at this and abused Gangamāla, but the king begged him to forgive her. Gangamāla returned to Gandhamādana, though urged by Udaya to stay in the royal park.
Ananda was Addhamāsaka, and Rāhulamātā was the queen.
The story was related by the Buddha to some lay-followers to en-courage them in their observance of the Uposatha (J.iii.444ff).
Gangamāla is mentioned as an example of a man who realised the evils of tanhā and renounced desire. E.g., J.iv.174.