When a religious movement gains a respectable number of followers, they have to seek legitimation from the government because they need help from the state so that they may spread its teachings more effectively. Beside that, a new religious movement needs the support of a standing army in order to protect their beliefs. Throughout history there are numerous examples of the downfall or sudden rise of religious movements, depending on the lack or the presence of a standing army on their side. The same thing happened with Mazdakism, where the founder (Mazdak) managed to convert the Sasanian ruler, Kavadh I (you can read more about it in the first part of the article, here). Mazdakism had an enormous success, but its teachings were too dangerous for the ruling nobility and priests, so the Sasanian Empire fell into a war of succession soon after the conversion of Kavadh I.
Kavadh I used Mazdak in subverting the power of the nobility and clergy who had weakened the power of the king, which also brought him popular support and made him and Mazdak a populist king and priest. We can tell that Mazdak was a populist and that his doctrines were supported by the lower classes because the sources state that Mazdak had styled himself the spiritual leader of the Zoroastrian religion, bringing aid to the hungry and the naked (gursag ud brahnag). Other people from the lower classes, according to the sources, seem to be the young mob (Jawan-mardan) who plundered the rich in the cities in order to feed the poor. Also, the king established an office dealing with the downtrodden masses who needed aid (the office of the “Protector of poor and the judge”).
During the late Sasanian period charitable foundations were established for the sake of one’s soul and the money was used for the poor or fow public construction projects that benefited the community and were a model for the later Islamic waqf. From this time Mazdakite propagandists went as far as the Arabian Peninsula, supported by Kavadh I, and where the empire established its base the Mazdakites were able to establish themselves too. How much influence these Mazdakites had on Arabia and the Islamic doctrine cannot be known, but their presence in Mecca was strong. 
Kavadh’s son, Prince Noshirvan, summoned the Zoroastrian priests to consider the situation. It was certain that the cult would spread and he adopted strict measures to suppress it, because he believed that it is a menace to the public peace. The clergy, who regarded the new heresy with great alarm, advised rigorous measures to exterminate the threatening creed. Mazdak did not live long to preach his doctrine. In 528. A.D. the prince arranged a banquet for him and his followers, where all of the guests were murdered. Even when the anti-Mazdakite Khosrau I came to power, the Mazdakites were able to survive in the distant places away from Persia, specifically in Arabia. At the end of Kavad’s life (531) there were conflicts in terms of succession and the Mazdakites were defeated by Khosrau I who had the aid of the anti-Mazdakite faction. When he came to power, he repaid his constituents, while many of Mazdak’s followers were killed. As a result, the interpretation of the Avesta and its teachings was restricted. 
By all accounts, one of the most interesting facts of Mazdakism is its social message. Mazdak wanted to create an egalitarian system for the distribution of wealth at a time of famine, which would have deepened the social tensions. Zoroastrian sources see Mazdak as a powerful heretic who commanded that women, children and property be shared among the population, which resulted in social chaos. The sources for this teachings inform us that sons did not know who their fathers were and so they could not determine their class affiliation. Patricia Crone has suggested that Mazdak generalized the institution of levirate wife, in which a man without male issue can give his wife in levirate marriage to another man. This means that the Mazdakites would have made that kind of marriage possible between classes as well, and maybe forced such an issue with the backing of the Sasanian ruler.
The lower classes have favored Mazdak’s proclamations and ideas which he claimed were based on the interpretation of the Avesta. In fact, Mazdak’s ideas then were not foreign, only that his interpretation of the Avesta was disliked by the nobility and the clergy priests who were attached to the state. Mazdak’s ideas were influenced by Zardosht from the city of Fasa, whose followers were called those who follow “the right religion” (drist-den). He probably lived in the 5th century A.D. and was a predecessor of Mazdakism. The Mazdakites who followed the teaching of Zardosht and then Mazdak are said to prescribe all the good qualities asked from a Zoroastrian: preaching righteous deeds, abstaining from sin and the practice of sacerdotal functions. What they lacked, however, was that they were less bent on following rites and rituals. This means that their interpretation was a means of remedying the social and economic hardships of the period after the Hephthalite onslaught, famine and social tensions. The Mazdakites also believed in matrilineal descent. Most other minor religious groups in the Sasanian Empire were contradictory to the Zoroastrianism established by the Sasanians.
Mazdak may have been among those heretics who was known as one who distorted a precept as it had been taught by the ancient teachers through interpretation. But as with all matters regarding history, they need to be put in accordance with the historical context. He distorted the precepts of the religion which seems to mean that he gave an esoteric interpretation to the Avesta and favored ascetic practices. Nevertheless, Mazdak remains one of the most mystic figures of Zoroastrian and Iranian history. Nowadays he is regarded as a proto-socialist and as a fighter for equality among all people regardless of their differences.