Viswamitra was the son of king Gadhi and hence was a Kshatriya. After his father he becomes the king. Once when he was wandering in the forest for hunting, and had become very weak, due to thirst and hunger, he reached at the hermitage of Sage Vasishtha.
As described in Mahabharata Adi Parva SECTION CLXXVII, sage Vasishtha has welcomed him and his army properly by the grace of divine cow Nandini. This divine cow was able to fulfill all demands of anyone. After seeing that cow, king Viswamitra desired for her.
And, O prince, the son of Gadhi, gratified with everything and applauding the cow named Nandini, addressed the Rishi, saying, 'O Brahmana, O great Muni, give me thy Naridini in exchange for ten thousand kine, or my kingdom. Enjoy thou my kingdom (giving me thy cow).
But sage Vasishtha has refused to give the cow.
Hearing these words of Viswamitra, Vasishtha said, 'O sinless one, this cow hath been kept by me for the sake of the gods, guests, and the Pitris, as also for my sacrifices. I cannot give Nandini in exchange for even thy kingdom.
After that there was a great battle between Viswamitra and Vasishtha. And finally sage Vasishtha has been victorious. Then Viswamitra has thought that Brahmana has more power than Kshatriya. Then he decided to become a Brahmarshi.
Viswamitra, beholding this wonderful feat that resulted from Brahmana prowess, became disgusted with Kshatriya prowess and said, 'O, fie on Kshatriya prowess! Brahmana prowess is true prowess! In judging of strength and weakness, I see that asceticism is true strength.' Saying this, the monarch, abandoning his large domains and regal splendour and turning his back upon all pleasures, set his mind on asceticism. Crowned with success in asceticism and filling the three worlds with the heat of his ascetic penances, he afflicted all creatures and finally became a Brahmana. The son of Kusika at last drank Soma with Indra himself (in Heaven).
After that in SECTION CLXXVIII, the story of Sage Vasishtha son is described. Sage Vasishtha has hundred sons, eldest of them is Saktri.
There was, O Partha, a king in this world, named Kalmashapada, who was of the race of Ikshvaku and was unequalled on earth for prowess. One day the king went from his capital into the woods for purposes of hunting, and this grinder of foes pierced (with his arrows) many deer and wild boars. And in those deep woods the king also slew many rhinoceroses. Engaged in sport for some length of time, the monarch became very much fatigued and at last he gave up the chase, desiring to rest awhile.
"The great Viswamitra, endued with energy, had, a little while ago, desired to make that monarch his disciple. As the monarch, afflicted with hunger and thirst, was proceeding through the woods, he came across that best of Rishis, the illustrious son of Vasishtha, coming along the same path. The king ever victorious in battle saw that Muni bearing the name of Saktri, that illustrious propagator of Vasishtha's race, the eldest of the high-souled Vasishtha's hundred sons, coming along from opposite direction. The king, beholding him said, 'Stand out of our way.' The Rishi, addressing the monarch in a conciliatory manner, said unto him sweetly, 'O king, this is my way. This is the eternal rule of morality indicated in every treatise on duty and religion, viz., that a king should ever make way for Brahmanas.' Thus did they address each other respecting their right of way. 'Stand aside, stand aside', were the words they said unto each other. The Rishi, who was in the right, did not yield, nor did the king yield to him from pride and anger. That best of monarchs, enraged at the Rishi, refusing to yield him the way, acted like a Rakshasa, striking him with his whip. Thus whipped by the monarch, that best of Rishis, the son of Vasishtha, was deprived of his senses by anger, and speedily cursed that first of monarchs, saying, 'O worst of kings, since thou persecutest like a Rakshasa an ascetic, thou shalt from this day, became a Rakshasa subsisting on human flesh! Hence, thou worst of kings! thou shalt wander over the earth, affecting human form!' Thus did the Rishi Sakti, endued with great prowess, speak unto king Kalmashapada. At this time Viswamitra, between whom and Vasishtha there was a dispute about the discipleship of Kalmashapada, approached the place where that monarch and Vasishtha's son were. And, O Partha, that Rishi of severe ascetic penances, viz., Viswamitra of great energy, approached the pair (knowing by his spiritual insight that they had been thus quarrelling with each other). After the curse had been pronounced, that best of monarchs knew that Rishi to be Vasishtha's son and equal unto Vasishtha himself in energy. And, O Bharata, Viswamitra, desirous of benefiting himself, remained on that spot, concealed from the sight of both by making himself invisible. Then that best of monarchs, thus cursed by Saktri, desiring to propitiate the Rishi began to humbly beseech him. And, O chief of the Kurus, Viswamitra, ascertaining the disposition of the king (and fearing that the difference might be made up), ordered a Rakshasa to enter the body of the king. And a Rakshasa of the name of Kinkara then entered the monarch's body in obedience to Saktri's curse and Viswamitra's command. And knowing, O chastiser of foes, that the Rakshasa had possessed himself of the monarch, that best of Rishis, Viswamitra, then left the spot and went away.
After that, the Rakshas first killed sage Saktri and then his younger brothers.
A little while after, O Bharata, that best of monarchs, deprived of all his senses by the Rakshasa within him, beholding Saktri who had cursed him, said, 'Because thou hast pronounced on me this extraordinary curse, therefore, I shall begin my life of cannibalism by devouring thee.' Having said this, the king immediately slew Saktri and ate him up, like a tiger eating the animal it was fond of. Beholding Saktri thus slain and devoured, Viswamitra repeatedly urged that Rakshasa (who was within the monarch) against the other sons of Vasishtha. Like a wrathful lion devouring small animals, that Rakshasa soon devoured the other sons of the illustrious Vasishtha that were junior to Saktri in age. But Vasishtha, learning that all his sons had been caused to be slain by Viswamitra, patiently bore his grief like the great mountain that bears the earth. That best of Munis, that foremost of intelligent men, was resolved rather to sacrifice his own life than exterminate (in anger) the race of Kusikas.