For much of its history, Japanese society did not possess a hierarchical class structure. Although there were always different strata of wealth and relative power, the Japanese polity tended for much of its history to align into vertical factions based on patron-client ties rather than horizontal factions based on "social classes" in the traditional post-Marxian sense of that term. This system of vertical alliances allowed for a certain social mobility and a volitily in socioeconomic boundaries that climaxed in the Sengoku Era, when priests could be warriors, warriors could be peasants, and peasants could become ruler of all Japan.
But in the Edo Period that followed, a strict social class system emerged from the quite literal ashes of the tumultuous Sengoku Era. This system had its origins in the "Sword Hunt" of 1588, in which Toyotomi Hideyoshi decreed that only samurai could own swords in an attempt to cut off the very social mobility that had allowed his own rise from peasant to master of Japan. The Tokugawa shoguns, in their singleminded quest to create a static society which would never change (and thus a society in which their rule would never be threatened), strengthened nacent class divisions by borrowing wholesale the ancient Chinese Confucian class system and writing it into law with elaborate sumptuary regulations detailing exactly how each class could dress, eat, and shelter themselves.
This system became known as shi-nô-kô-shô, after the Japanese transliteration of the four traditional Chinese classes. At the top were the warriors, or shi (士), followed by the farmers, or nô (農), the craftsmen, or kô (工), and the merchants, or shô (商). Also included in the system, if not the catchy four-syllable name, were the courtly nobility, or kuge, who were theoretically superior to the shi but in reality were powerless, and the henin, or untouchables, who were the lowest of the low.
This system was not exactly perfectly suited for the Japanese situation, incorporating as it did such alien elements as the traditional Chinese disdain for merchants, and actually contributed to the rise of Japan's merchant class as the merchants were, despite their growing wealth, required to spend the least under the sumptuary regulations, even less than the chronically poor farmers.
Although the Japanese class system has long since been written out of the law books, and equal rights allegedly rule the land, the Japanese are still aware of class distinctions to some degree. Most Japanese, even today, still know which class their family once belonged to (which can be determined to some extent by family names), and having a samurai background is still worth some pride points, while belonging to a family that had been merchants or worse yet untouchables is still cause for concealment.