Japanese castes under the Ritsuryō

Ryōmin (良民) and Senmin (賤民) were the two main castes of the classical Japan caste system.

When the Ritsuryō legal system was starting to be enforced in Japan at the end of the 7th century, it included, as in Tang China, a division between those two major castes. The term Ryosensei (良賤制) describes the whole system. The Senmin caste, divided into five "genres", is also called Goshiki no Sen (五色の賤), the Senmin of five genres, sometimes abbreviated to gosen (五賤).

Caste was part of the citizen registration enforced with the ritsuryō.

Ryōmin
The Ryōmin (lit. Good citizens) were the upper-class, divided into the four following subcastes
 * Kanjin (官人), government officials
 * Kōmin (公民), citizens
 * Shinabe (品部), professionals and tradesmen relevant to court functions
 * Zakko (雑戸), tradesmen, especially those relevant to the military, considered of a lower class than the previous three

Senmin
The Senmin (lit. low citizens) were the lower-class, divided into the five following subcastes:
 * Ryōko (陵戸), dedicated to the imperial family or guards of imperial tombs
 * Kanko (官戸), dedicated to public ministries
 * Kenin (家人), servants of high-ranking families
 * Kunuhi (公奴婢), slaves of the court
 * Shinuhi (私奴婢), slaves of families

Intercaste marriage was at first not allowed. Ryōko, Kanko and Kenin were allowed to have their own families.

The lowest two levels of citizens (Nuhi, slaves) could be sold or owned by Ryōmin citizens, and were not allowed to have a registered family. This caste system was not very rigid, in the sense that Kunuhi could become Kanko when they got older (66), and automatically freed at very old age (76) but this is unlikely as most people would not reach the age of 66 and over during these times, and Ryōmin could become Senmin (at the Kanko level) after having committed some crimes.

At first, children born between Ryōmin and Senmin would become Senmin. In 789, this changed and children born between Ryōmin and Senmin were Ryōmin. The Senmin was a minority of the whole population.