From the late 1100s until 1867, military rulers usually held the real power in Japan. The emperor kept his title and lived in Kyoto.
The first lasting military government began after the warrior Minamoto Yoritomo defeated a rival clan, the Taira. The emperor's court gave him the title shogun, meaning "general." Some books date the start of his rule to 1185, when he won the war, and others to 1192, when he became shogun. Yoritomo ruled from Kamakura, a town in eastern Japan. His government is called a shogunate.
Below the shogun were the daimyo, great lords who controlled large areas of land. Their title comes from words meaning "large" and "private land." Daimyo relied on samurai, trained warriors who served a lord. Samurai is often translated as "those who serve."
In the late 1400s and 1500s, shoguns grew weak and daimyo fought one another for land. In 1603, Tokugawa Ieyasu became shogun. The Tokugawa shoguns ruled from Edo, today's Tokyo, and kept Japan mostly at peace for more than 250 years.
Ideas about how warriors should act were old, but writers described bushido, "the way of the warrior," mostly during this peace and later. It was an ideal of loyalty, courage and honor. Real samurai did not always live up to it. In 1899, a book in English by Nitobe Inazo made the idea widely known.
In 1868, the emperor's supporters ended the shogunate and returned power to him. This change is called the Meiji Restoration. By the late 1870s, samurai had lost their special rights.