The Jataka, Vol. II, tr. by W.H.D. Rouse, , at sacred-texts.com
"The Yellow King," etc.--This story the Master told at the Jetavana Park, about Devadatta the heretic.
Devadatta for nine months had tried to compass the destruction of the future Buddha, and had sunk down into the earth by the gateway of Jetavana.
[paragraph continues] Then they that dwelt at Jetavana and in all the country round about were delighted, saying, "Devadatta the enemy of Buddha has been swallowed up in the earth: the adversary is slain, and the Master has become perfectly enlightened!"  And hearing these words spoken many a time and oft, the people of all the continent of India, and all the goblins, and living creatures, and gods were delighted likewise. One day, all the brethren were talking together in the Hall of Truth, and thus would they say: "Brother, since Devadatta sank into the earth, what a number of people are glad, saying, Devadatta is swallowed up by the earth!" The Teacher entered, and asked, "What are ye all talking about here, brethren?" They told him. Then said he, "This is not the first time, O brethren, that multitudes have rejoiced and laughed aloud at the death of Devadatta. Long ago they rejoiced and laughed as they do now." And he told them an old-world tale.
Once upon a time reigned at Benares a wicked and unjust king named Mahā-piṅgala, the Great Yellow King, who did sinfully after his own will and pleasure. With taxes and fines, and many mutilations 1 and robberies, he crushed the folk as it were sugar-cane in a mill; be was cruel, fierce, ferocious. For other people he had not a grain of pity; at home he was harsh and implacable towards his wives, his sons and daughters, to his brahmin courtiers and the householders of the country. He was like a speck of dust that falls in the eye, like gravel in the broth, like a thorn sticking in the heel.
Now the Bodhisatta was a son of king Mahā-piṅgala. After this king had reigned for a long time, he died. When he died all the citizens of Benares were overjoyed and laughed a great laugh; they burnt his body with a thousand cartloads of logs, and quenched the place of burning with thousands of jars of water, and consecrated the Bodhisatta to be king: they caused a drum of rejoicing to beat about the streets, for joy that they had got them a righteous king. They raised flags and banners, and decked out the city; at every door was set a pavilion, and scattering parched corn and flowers, they sat them down upon the decorated platforms under fine canopies, and did eat and drink. The Bodhisatta himself sat upon a fine divan  on a great raised dais, in great magnificence, with a white parasol stretched above him. The courtiers and householders, the citizens and the doorkeepers stood around their king.
But one doorkeeper, standing not far from the king, was sighing and sobbing. "Good Porter," said the Bodhisatta, observing him, "all the people are making merry for joy that my father is dead, but you stand weeping. Come, was my father good and kind to you?" And with the question he uttered the first stanza:--
The man heard, and answered: "I am not weeping for sorrow that Piṅgala is dead. My head would be glad enough. For King Piṅgala, every time he came down from the palace, or went up into it, would give me eight blows over the head with his fist, like the blows of a blacksmith's hammer. So when he goes down to the other world, he will deal eight blows on the head of Yama, the gatekeeper of hell, as though he were striking me. Then the people there will cry--He is too cruel for us! and will send him up again. And I fear he will come and deal fisticuffs on my head again, and that is why I weep." To explain the matter he uttered the second stanza:--
Then said the Bodhisatta: "That king has been burnt with a thousand cartloads of wood; the place of his burning has been soaked with water from thousands of pitchers, and the ground has been dug up all round; beings that have gone to the other world, except by force of fate 1, do not return to the same bodily shape as they had before; do not be afraid!" and to comfort him, he repeated the following stanza
After that, the porter took comfort. And the Bodhisatta ruled in righteousness; and after giving gifts and doing other good acts, he passed away to fare according to his deserts.
When the Master had ended this discourse, he identified the Birth:--"Devadatta was Piṅgala; and his son was I myself."
165:1 Folk-Lore Journal, iii. 126.
166:1 -jaṁghakahāpaṇādigahanena I take to mean 'the taking away of legs, money, etc.' Possibly jaṁghā (taking it independently) may mean something like 'boot' or 'stocks,' but I can find no authority for this.
167:1 Reading aññatra gativasā, 'except by the power of rebirth.'