Most samurai were bound by a code of honor and were expected to set an example for those below them. A notable part of their code is seppuku (切腹 seppuku) or hara kiri, which allowed a disgraced samurai to regain his honor by passing into death, where samurai were still beholden to social rules.
Samurai were usually loyal to their immediate superiors, who in turn allied themselves with higher lords. These loyalties to the higher lords often shifted; for example, the high lords allied under Toyotomi Hideyoshi (豊臣秀吉) were served by loyal samurai, but the feudal lords under them could shift their support to Tokugawa, taking their samurai with them. There were, however, also notable instances where samurai would be disloyal to their lord (daimyō), when loyalty to the Emperor was seen to have supremacy.