Goshiki no Sen (the lowly persons of five kinds) (五色の賤)
There is a theory that the origin of discrimination during the medieval period, as well as those living in special hamlets in modern Japan, lies in goshiki no sen; however, this fact is often debated.
The Ritsuryo system, brought in Japan during the latter half of the seventh century, adopted the Ryosen system which largely divided the people into the Ryomin (lit. good people) and the Senmin (the lowly persons) after a model from China (the Law of Ryosen, enacted in 645). Each division was further classified as below.
From the fact that the Senmin were required to wear color-coded clothes, they were collectively called Goshiki no sen (lit. the lowly persons in five colors). Ryoko were those who were demoted to the lowly status as a result of the enforcement of the Yoro Penal and Administrative Codes and were treated the same as Ryomin, except for their rights concerning marriage. Kanko were those who were demoted to the lowly status as punishment for their criminal acts and were granted the same farming rights as Ryomin. They were pardoned and returned to the Ryomin when they turned 76 years old. Kunuhi were subdivided into two types; those who inherited this status and those who had been reduced due to a penalty for a criminal act, both of which were pardoned to return to the Ryomin when they became 60 years old and 76 years old, respectively. Kunuhi were not allowed to raise a family. Shinuhi, or privately owned slaves, who were each given one-third of land given to an ordinary person by the government, could be traded and inherited. Kenin, or household servants, had the same status as shinuhi but it was forbidden to trade kenin and their occupational choice was limited.
Occupations of the lowly persons
Ryoko were engaged in the protection of the mausoleums of emperors and imperial family members; kanko and kunuhi in the cultivation of government-owned land; and kenin and shinuhi in the performance of chores for private households. Ryoko were under the control of Shoryoryo (the Bureau of Imperial Mausolea) (or Shoryoji), and Kanko and Kunuhi were under the control of Yakko-no-tsukasa (director in charge of registers of male and female public slaves, and their allotment lands), later Tonomori-no-tsukasa (Bureau of Household).
Social status of the lowly persons
Kunuhi and shinuhi, who were traded and pawned, were not treated as human beings. However there was a system in place which allowed them to rise to a higher status once they reached a certain age; therefore, their status was not as tightly fixed as those who were discriminated in the Edo period who were treated as a kind of outcast segregated from samurai, farmers, and townsmen for their filth. On the other hand, nuhi did not have any official independent community for themselves and were individually treated as property of the Ryomin or the Imperial court; therefore, their basis to secure their rights was probably more fragile when compared to others who were discriminated in the Edo period who found some security in their communities headed by Etagashira (head of eta (discriminated people) which secured their rights.
Collapse of the system
As the imperial court was no longer able to maintain control over the population based on the land allotment system and the family registration system and depended more and more on indirect means of control through rich families (called "tato fumyo" in Japanese) who were subcontracted for the management of farmland, the Ritsuryo system gradually collapsed and the status system itself was reduced to a nominal existence. Marriages between ryomin and senmin gradually became tolerated and some ryomin even sought to be exempted from taxes by marrying senmin. In 789, it was ordained that children born between the Ryomin and the Senmin should become the Ryomin, and in 907, the nuhi system was abolished.
(In another opinion, the nuhi system had already been abolished in the Kanpyo era at the end of the ninth century.)
Therefore, it can be concluded that the ancient lowly persons and those discriminated after the medieval period as well as communities of discriminated people during the Edo period which came to be called burakumin (people come from or live in special hamlets) in the modern period and after were not connected historically and had different origins.