The samurai (samurai = one who serves) were warriors in the Heian period. Samurai highly values honor above life. He is not a simple soldier. Samurai originally ranked beneath the nobility. However they gradually rose to power and established a military style government known as a shogunate. I have written about the first shogunate on this website in my article Kamakura Shogunate. The Kamakura period was the first period in Japanese history when non-aristocratic samurai class assumed political power over the realm.
The samurai held power during the Kamakura and Muromachi periods and imperial authority diminished considerably during these times.
It was very interesting for me to learn that the famous Japanese movie director Akira Kurosawa (1910-1998) was born into an old samurai family. It was clear to me why he would deal with samurai in his movies. Actually a film about them made him famous. It was Shichinin no Samurai, i.e. Seven Samurai, which he directed in 1954 and is nowadays considered a cult film. This movie even inspired making of The Magnificent Seven, a western where the action was shifted from Japan to the American West.