The samurai (or bushi) were the warriors of premodern Japan. They later made up the ruling military class that eventually became the highest ranking social caste of the Edo Period (1603-1867). Samurai were supposed to lead their lives according to the ethic code of Bushidō, meaning "Way of the Warrior", it is a Japanese word for the way of the samurai, loosely analogous to the concept of chivalry. It originates from the samurai moral code and stresses frugality, loyalty, martial arts mastery, and honor unto death. Born from Neo-Confucianism during times of peace in Tokugawa Japan and following Confucian texts, Bushido was also influenced by Shinto and Buddhism, allowing the violent existence of the samurai to be tempered by wisdom and serenity. Bushidō developed between the 9th and 20th centuries and numerous translated documents dating from the 12th to 16th centuries demonstrate its wide influence across the whole of Japan. Strongly Confucian in nature, bushido stressed concepts such as loyalty to one's master, self discipline and respectful, ethical behavior. Many samurai were also drawn to the teachings and practices of Zen Buddhism.
The philosophies of Buddhism and Zen, and to a lesser extent Confucianism and Shinto, influenced the samurai culture. Zen meditation became an important teaching due to it offering a process to calm one's mind. The Buddhist concept of reincarnation and rebirth led samurai to abandon torture and needless killing, while some samurai even gave up violence altogether and became Buddhist monks after realizing how fruitless their killings were. Some were killed as they came to terms with these realizations in the battlefield. The most defining role that Confucianism played in samurai philosophy was to stress the importance of the lord-retainer relationship; this is, the loyalty that a samurai was required to show his lord.