Samurai () were the hereditary military nobility and officer caste of medieval and early-modern Japan from the late 12th century to their abolition in 1876. They were the well-paid retainers of the daimyo (the great feudal landholders). They had high prestige and special privileges such as wearing two swords. They cultivated the bushido codes of martial virtues, indifference to pain, and unflinching loyalty, engaging in many local battles. Though they had predecssors in earlier military and administrative officers, the samurai truly emerged during the Kamakura shogunate, ruling from c. 11851333. They became the ruling political class, with significant power but also significant responsibility. During the 1200s, the samurai proved themselves as adept warriors against the invading Mongols. During the peaceful Edo era (1603 to 1868) they became the stewards and chamberlains of the daimyo estates, gaining managerial experience and education. In the 1870s samurai families comprised 5% of the population. As modern militaries emerged in the 1800s, Japan faced growing threats from China and a desire to rival the great powers.