No one is quite sure who the first samurai was. Historians do have some idea of when regular warriors began taking on the characteristics of the samurai. In the 5th, 6th, and 7th centuries, A.D., there were rivalries in Japan between princes and clans, as well as succession wars when an emperor died. However, most of the fighting was done against those people who were native to islands of Japan, which imperial Japanese referred to as emishi, or barbarians.
Some emperors realized that the emishi were good fighters, and in later years, emishi were recruited to fight in battles against other clans or rebellious religious orders. Some of the military tactics and traditions of the emishi were incorporated by Japanese soldiers, and were later used by the samurai.
The samurai's status as an elite class comes from the proliferation of powerful families that lived far from the capital, passing their land, and their prestige, from one generation to the next for hundreds of years. The members of these warrior houses or clans attained noble status.
Barbarian military traditions combined with elite status and the kyuba no michi warrior code to form a template for the earliest samurai. By some reports, the word samurai first appeared in the 12th century. For a long time, the samurai provided the main military force used against emishi and other clans.
In the 1100s, two powerful clans served the emperor of Japan: the Taira clan, and the Minamoto clan. These two families became bitter rivals, and in 1192, Minamoto Yoritomo led his clan to victory over the Taira. The emperor, the traditional head of the Japanese government, declared Minamoto Yoritomo shogun, the head of the military. However, Yoritomo used his new power to strip the emperor of all political power, make his position as shogun permanent, and set up a military dictatorship known as bakufu. So, the samurai went from being servants to the land-owning daimyos to being the rulers of Japan under the shogun.
After Yoritomo died, his wife, Masa-ko, worked to hold the shogunate together. Though not perfect, her family, the Hojos, maintained control over Japan for over 100 years.
The Ashikaga clan wrested control from the Hojos in 1338. The Ashikagas failed to provide a strong central authority in Japan, and the clans descended into constant fighting. During this period, daimyo built impressive castles with walls, gates, and moats that made them difficult to attack.
This sengoku, or civil war period lasted until Tokugawa Ieyaso took control of Japan in 1603. Tokugawa enforced a strict isolationist policy, and kept control of the daimyos by forcing their families to live in the capital, while the daimyo himself lived on his estate. Each daimyo was required to visit the capital at least once per year (daimyos who fell into disfavor were given estates far from the capital, making the trip much more expensive and time-consuming). This policy ensured the control of the daimyos because their families were basically held hostage, and the expensive annual trips prevented them from gaining too much economic power.
Tokugawa also banned the carrying of swords by anyone but samurai. All swords owned by non-samurai were confiscated and melted down to make statues. This marked the samurai as a very distinct and noticeable class, above the common citizen.
During Tokugawa's enforced peace, samurai were seldom used in combat. It was during this period that the samurai took on other roles, escorting their lords back and forth from the capital, working as bureaucrats in the bakufu, and collecting tribute in the form of rice payments from the daimyo's vassals.