The primary difference between a ninja and a samurai is that a ninja is skilled in ninjutsu and a samurai practices bushido. Ninjutsu is the art of stealth and sabotage developed for espionage. Bushido is a code of honor and morals.
Japanese folklore suggests that ninjas descended from a demon. Scholars believe ninjutsu developed sometime around the sixth century in opposition to the early feudal samurai. Ninjutsu was a blend of Indo-Chinese and Japanese tactics developed by a denounced samurai and a Chinese monk. Ninjutsu ignored the bushido code and valued covert action.
Early samurai warriors supported the wealthy property owners of feudal Japan. By the 12th century, the samurai were gaining military and political control. Following the Gempei War in 1185, the samurai established the Kamakura Shogunate as a military dictatorship. The dictatorship lasted into the 19th century.
The ninjas could come from the upper class as disgraced samurai or from the lower class as sons of farmers or villagers. Ninjas rank from ordinary ninja, or genin, to intermediary, or chunin, to high man, or jonin.
The decline of the samurai occurred subsequent to the introduction of Western culture in Japan in the mid-19th century. Japanese legislature abolished feudalism in 1871, but the bushido code was evident in Japanese culture through World War II.