The story of Kaveh appears in Shahnameh, the epic masterpiece of Ferdowsi.
This is a summary of the first chapter of this book, copied from an excellent web-site for The Epic of Shahnameh Ferdowsi.
Kaiumers first sat upon the throne of Persia, and was master of the world. He took up his abode in the mountains, and clad himself and his people in tiger-skins, and from him sprang all kindly nurture and the arts of clothing, till then unknown. Men and beasts from all parts of the earth came to do him homage and receive laws at his hands, and his glory was like to the sun. Then Ahriman the Evil, when he saw how the Shah's honour was increased, waxed envious, and sought to usurp the diadem of the world. So he bade his son, a mighty Deev, gather together an army to go out against Kaiumers and his beloved son Saiamuk and destroy them utterly.
Now the Serosch, the angel who defendeth men from the snares of the Deevs, and who each night flieth seven times around the earth that he may watch over the children of Ormuzd, when he learned this, appeared like unto a Peri and warned Kaiumers. So when Saiamuk set forth at the head of his warriors to meet the army of Ahriman, he knew that he was contending against a Deev, and he put forth all his strength. But the Deev was mightier than he, and overcame him, and crushed him under his hands.
When Kaiumers heard the news of mourning, he was bowed to the ground. For a year did he weep without ceasing, and his army wept with him; yea, even the savage beasts and the birds of the air joined in the wailing. And sorrow reigned in the land, and all the world was darkened until the Serosch bade the Shah lift his head and think on vengeance. And Kaiumers obeyed, and commanded Husheng, the son of Saiamuk, "Take the lead of the army, and march against the Deevs." And the King, by reason of his great age, went in the rear. Now there were in the host Peris; also tigers, lions, wolves, and other fierce creatures, and when the black Deev heard their roaring he trembled for very fear. Neither could he hold himself against them, and Husheng routed him utterly. Then when Kaiumers saw that his well-beloved son was revenged he laid him down to die, and the world was void of him, and Husheng reigned in his stead.
Now Husheng was a wise man and just, and the heavens revolved over his throne forty years. justice did he spread over the land, and the world was better for his reign. For he first gave to men fire, and showed them how to draw it from out the stone; and he taught them how they might lead the rivers, that they should water the land and make it fertile; and he bade them till and reap. And he divided the beasts and paired them and gave them names. And when he passed to a brighter life he left the world empty of a throne of power. But Tahumers, his son, was not unworthy of his sire. He too opened the eyes of men, and they learned to spin and to weave; and he reigned over the land long and mightily. But of him also were the Deevs right envious, and sought to destroy him. Yet Tahumers overcame them and cast them to earth. Then some craved mercy at his hands, and sware how they would show him an art if he would spare them, and Tahumers listened to their voice. And they taught him the art of writing, and thus from the evil Deevs came a boon upon mankind.
Howbeit when Tahumers had sat upon the golden throne for the space of thirty years he passed away, but his works endured; and Jemshid, his glorious son, whose heart was filled with the counsels of his father, came after him. Now Jemshid reigned over the land seven hundred years girt with might, and Deevs, birds, and Peris obeyed him. And the world was happier for his sake, and he too was glad, and death was unknown among men, neither did they wot of pain or sorrow. And he first parcelled out men into classes; priests, warriors, artificers, and husbandmen did he name them. And the year also he divided into periods. And by aid of the Deevs he raised mighty works, and Persepolis was builded by him, that to this day is called Tukht-e-Jemsheed, which being interpreted meaneth the throne of Jemshid. Then, when these things were accomplished, men flocked from all corners of the earth around his throne to do him homage and pour gifts before his face. And Jemshid prepared a feast, and bade them keep it, and called it Neurouz, which is the New Day, and the people of Persia keep it to this hour. And Jemshid's power increased, and the world was at peace, and men beheld in him nought but what was good.
Then it came about that the heart of Jemshid was uplifted in pride, and he forgot whence came his weal and the source of his blessings. He beheld only himself upon the earth, and he named himself God, and sent forth his image to be worshipped. But when he had spoken thus, the Mubids, which are astrologers and wise men, hung their heads in sorrow, and no man knew how he should answer the Shah. And God withdrew his hand from Jemshid, and the kings and the nobles rose up against him, and removed their warriors from his court, and Ahriman had power over the land.
Now there dwelt in the deserts of Arabia a king named Mirtas, generous and just, and he had a son, Zohak, whom he loved. And it came about that Ahriman visited the palace disguised as a noble, and tempted Zohak that he should depart from the paths of virtue. And he spake unto him and said-
"If thou wilt listen to me, and enter into a covenant, I will raise thy head above the sun."
Now the young man was guileless and simple of heart, and he sware unto the Deev that he would obey him in all things. Then Ahriman bade him slay his father,
"for this old man,"
"cumbereth the ground, and while he liveth thou wilt remain unknown."
When Zohak heard this he was filled with grief, and would have broken his oath, but Ahriman suffered him not, but made him set a trap for Mirtas. And Zohak and the evil Ahriman held their peace and Mirtas fell into the snare and was killed. Then Zohak placed the crown of Thasis upon his head, and Ahriman taught him the arts of magic, and he ruled over his people in good and evil, for he was not yet wholly given up to guile.
Then Ahriman imagined a device in his black heart. He took upon himself the form of a youth, and craved that he might serve the King as cook. And Zohak, who knew him not, received him well and granted his request, and the keys of the kitchen were given unto him. Now hitherto men had been nourished with herbs, but Ahriman prepared flesh for Zohak. New dishes did he put before him, and the royal favour was accorded to his savory meats. And the flesh gave the King courage and strength like to that of a lion, and he commanded that his cook should be brought before him and ask a boon at his hands. And the cook said-
"If the King take pleasure in his servant, grant that he may kiss his shoulders."
Now Zohak, who feared no evil, granted the request, and Ahriman kissed him on his shoulders. And when he had done so, the ground opened beneath his feet and covered the cook, so that all men present were amazed thereat. But from his kiss sprang hissing serpents, venomous and black; and the King was afraid, and desired that they should be cut off from the root. But as often as the snakes were cut down did they grow again, and in vain the wise men and physicians cast about for a remedy. Then Ahriman came once again disguised as a learned man, and was led before Zohak, and he spake, saying
"This ill cannot be healed, neither can the serpents be uprooted. Prepare food for them, therefore, that they may be fed, and give unto them for nourishment the brains of men, for perchance this may destroy them."
But in his secret heart Ahriman desired that the world might thus be made desolate; and daily were the serpents fed, and the fear of the King was great in the land. The world withered in his thrall, the customs of good men were forgotten, and the desires of the wicked were accomplished.
Now it was spread abroad in Iran that in the land of Thasis there reigned a man who was mighty and terrible to his foes. Then the kings and nobles who had withdrawn from Jemshid because he had rebelled against God, turned to Zohak and besought him that he would be their ruler, and they proclaimed him Shah. And the armies of Arabia and Persia marched against Jemshid, and he fled before their face. For the space of twice fifty years no man knew whither he was gone, for he hid from the wrath of the Serpent-King. But in the fulness of time he could no longer escape the fury of Zohak, whose servants found him as he wandered on the sea-shore of Cathay, and they sawed him in twain, and sent tidings thereof to their lord. And thus perished the throne and power of Jemshid like unto the grass that withereth, because that he was grown proud, and would have lifted himself above his Maker.
So the beloved of Ahriman, Zohak the Serpent, sat upon the throne of Iran, the kingdom of Light. And he continued to pile evil upon evil till the measure thereof was full to overflowing, and all the land cried out against him. But Zohak and his councillors, the Deevs, shut ear unto this cry, and the Shah reigned thus for the space of a thousand years, and vice stalked in daylight, but virtue was hidden. And despair filled all hearts, for it was as though mankind must perish to still the appetite of those snakes sprung from Evil, for daily were two men slaughtered to satisfy their desire. Neither had Zohak mercy upon any man. And darkness was spread over the land because of his wickedness.
But Ormuzd saw it and was moved with compassion for his people, and he declared they should no longer suffer for the sin of Jemshid. And he caused a grandson to be born to Jemshid, and his parents called him Feridoun.
Now it befell that when he was born, Zohak dreamed he beheld a youth slender like to a cypress, and he came towards him bearing a cow-headed mace, and with it he struck Zohak to the ground. Then the tyrant awoke and trembled, and called for his Mubids, that they should interpret to him this dream. And they were troubled, for they foresaw danger, and he menaced them if they foretold him evil. And they were silent for fear three days, but on the fourth one who had courage spake and said
"There will arise one named Feridoun, who shall inherit thy throne and reverse thy fortunes, and strike thee down with a cow-headed mace."
When Zohak heard these words he swooned, and the Mubids fled before his wrath. But when he had recovered he bade the world be scoured for Feridoun. And henceforth Zohak was consumed for bitterness of spirit, and he knew neither rest nor joy.
Now it came about that the mother of Feridoun feared lest the Shah should destroy the child if he learned that he was sprung from Jemshid's race. So she hid him in the thick forest where dwelt the wondrous cow Purmaieh, whose hairs were like unto the plumes of a peacock for beauty. And she prayed the guardian of Purmaieh to have a care of her son, and for three years he was reared in the wood, and Purmaieh was his nurse. But when the time was accomplished the mother knew that news of Purmaieh had reached the ears of Zohak, and she feared he would find her son. Therefore she took him far into Ind, to a pious hermit who dwelt on the Mount Alberz. And she prayed the hermit to guard her boy, who was destined for mighty deeds. And the hermit granted her request. And it befell that while she sojourned with him Zohak had found the beauteous Purmaieh and learned of Feridoun, and when he heard that the boy was fled he was like unto a mad elephant in his fury. He slew the wondrous cow and all the living things round about, and made the forest a desert. Then he continued his search, but neither tidings nor sight could he get of Feridoun, and his heart was filled with anguish.
In this year Zohak caused his army to be strengthened, and he demanded of his people that they should certify that he had ever been to them a just and noble king. And they obeyed for very fear. But while they sware there arose without the doorway of the Shah the cry of one who demanded justice. And Zohak commanded that he should be brought in, and the man stood before the assembly of the nobles.
Then Zohak opened his mouth and said,
"I charge thee give a name unto him who hath done thee wrong."
And the man, when he saw it was the Shah who questioned him, smote his head with his hands. But he answered and said
"I am Kaveh, a blacksmith and a blameless man, and I sue for justice, and it is against thee, O King, that I cry out. Seventeen fair sons have I called mine, yet only one remaineth to me, for that his brethren were slain to still the hunger of thy serpents, and now they have taken from me this last child also. I pray thee spare him unto me, nor heap thy cruelties upon the land past bearing."
And the Shah feared Kaveh's wrath, beholding that it was great, and he granted him the life of his son and sought to win him with soft words. Then he prayed him that he would also sign the testimony that Zohak was a just and noble king. But Kaveh cried,
"Not so, thou wicked and ignoble man, ally of Deevs, I will not lend my hand unto this lie,"
and he seized the declaration and tore it into fragments and scattered them into the air. And when he had done so he strode forth from the palace, and all the nobles and people were astonished, so that none dared uplift a finger to restrain him. Then Kaveh went to the market-place and related to the people all that which he had seen, and recalled to them the evil deeds of Zohak and the wrongs they had suffered at his hands. And he provoked them to shake off the yoke of Ahriman. And taking off the leathern apron wherewith blacksmiths cover their knees when they strike with the hammer, he raised it aloft upon the point of a lance and cried
"Be this our banner to march forth and seek out Feridoun and entreat him that he deliver us from out the hands of the Serpent-King."
Then the people set up a shout of joy and gathered themselves round Kaveh, and he led them out of the city bearing aloft his standard. And they marched thus for many days unto the palace of Feridoun.
Now these things came about in the land of Iran after twice eight years were passed over the head of Feridoun. And when that time was accomplished, he descended from the Mount Alberz and sought out his mother, questioning her of his lineage. And she told him how that he was sprung from the race of Jemshid, and also of Zohak and of his evil deeds.
Then said Feridoun,
"I will uproot this monster from the earth, and his palace will I raze to the dust."
But his mother spake, and said,
"Not so, my son, let not thine youthful anger betray thee; for how canst thou stand against all the world?"
Yet not long did she suffer the hard task to hinder him, for soon a mighty crowd came towards the palace led by one who bare an apron uplifted upon a lance. Then Feridoun knew that succour was come unto him. And when he had listened to Kaveh, he came into the presence of his mother with the helmet of kings upon his head, and he said unto her
"Mother, I go to the wars, and it remaineth for thee to pray God for my safety."
Then he caused a mighty club to be made for him, and he traced the pattern thereof upon the ground, and the top thereof was the head of a cow, in memory of Purmaieh, his nurse. Then he cased the standard of Kaveh in rich brocades of Roum, and hung jewels upon it. And when all was made ready, they set forth towards the West to seek out Zohak, for, they knew not that he was gone to Ind in search of Feridoun. Now when they were come to Bagdad, which is upon the banks of the Tigris, they halted, and Feridoun bade the guardians of the flood convey them across. But these refused, saying, the King bade that none should pass save only those who bore the royal seal. When Feridoun heard these words he was wroth, and he regarded not the rushing river nor the dangers hidden within its floods. He girded his loins and plunged with his steed into the waters, and all the army followed after him. Now they struggled sore with the rushing stream, and it seemed as though the waves would bear them down. But their brave horses overcame all dangers, and they stepped in safety upon the shore. Then they turned their faces towards the city which is now called Jerusalem, for here stood the glorious house that Zohak had builded. And when they had entered the city all the people rallied round Feridoun, for they hated Zohak and looked to Feridoun to deliver them. And he slew the Deevs that held the palace, and cast down the evil talisman that was graven upon the walls. Then he mounted the throne of the idolater and placed the crown of Iran upon his head, and all the people bowed down before him and called him Shah.
Now when Zohak returned from his search after Feridoun and learned that he was seated upon his throne, he encompassed the city with his host. But the army of Feridoun marched against him, and the desires of the people went with them. And all that day bricks fell from the walls and stones from the terraces, and it rained arrows and spears like to hail falling from a dark cloud, until Feridoun had overcome the might of Zohak. Then Feridoun raised his cow-headed mace to slay the Serpent-King. But the blessed Serosch swooped down, and cried
"Not so, strike not, for Zohak's hour is not yet come."
Then the Serosch bade the Shah bind the usurper and carry him far from the haunts of men, and there fasten him to a rock. And Feridoun did as he was bidden, and led forth Zohak to the Mount Demawend. And he bound him to the rock with mighty chains and nails driven into his hands, and left him to perish in agony. And the hot sun shone down upon the barren cliffs, and there was neither tree nor shrub to shelter him, and the chains entered into his flesh, and his tongue was consumed with thirst. Thus after a while the earth was delivered of Zohak the evil one, and Feridoun reigned in his stead.