Samurai were feted as legendary, high-skilled, and very deadly warriors. In medieval Japan they were the elite soldiers, and often served powerful landowners (such as the daimyo). From the late 12th Century, through to the latter part of the 19th Century, samurai built reputation for honourable combat, a devotion to duty, and unwavering, loyal service to their masters. They also came to wield not inconsiderable political power in their own right, but also carried a lot of responsibility in the process.
There is a great deal of romanticism regarding samurai. Their loyalty to their immediate superiors was noteworthy, but not absolute; if the loyalty of their superiors were to shift, not all samurai would follow in turn. Political power shifts would carry as much influence over a samurai as anyone else.
I’ll confess that my personal knowledge of samurai is highly limited, and no doubt heavily influenced by popular culture. Their image as noble warriors is a strong one, though it was not unheard of for samurai to be as cowardly or cruel as any other feudal group. One interesting outlier is that there were women samurai, albeit their role was to protect the home (another way of suggesting they be helpmeets). However, women samurai were trained to fight if necessary, especially to protect their home.
Whilst samurai were said to practice sophisticated combat, especially within the concept of bushido, a code of conduct that is considered loosely similar to chivalry, they were also prepared to be quite practical on the battlefield, if the need arose. After all, an unnecessary death could also be considered a dishonourable one.
The influence and power of the samurai began to fade as Japan moved towards more sophisticated forms of warfare, and more organised armies. They were abolished early into the Meiji Era, in the 1870s, and the samurai themselves took on different roles in society. Modern Japan continues to venerate the romanticised image of the samurai, who at their best greatly embodied concepts that the world could do with reminding of.