The first shogun was a man named Yoritomo. He was in a clan called Minamoto. They were in a huge war with a rival clan by the name of Taira.
In 1185, the rival clans were in great battle at sea. The young emperor, Antoku, resisted capture so jumped overboard with his royal sword. But both Antoku and his sword sank to the ocean floor.
Minamoto Yoritomo was victorious! He was later got the title of shogun, or supreme military commander. The title was only temporary, but he intended on keeping it for a long while.
The rule of the shoguns were often violent and lawless. They were fierce military leaders who held most power. The emperor was just a "figurehead".
The daimyo is under the shogun in the Japanese society. It was up to him to protect people from the vicious shogun. A daimyo is a local land owner. He relied on peasants to work his land. In return he would offer them protection. This protection was provided by a small army of samurai, or skilled warriors. The daimyo offered the samurai land or money for their service.
The samurai were highly skilled warriors. They protected the daimyo. The samurai had words to live by: honor and loyalty to ones lord. These words made up the warrior code called bushido. This was a strict code created to guide the behavior of the samurai. The word samurai means "those who serve". The samurai would die with sword in hand.