A ninja or shinobi (忍者 or 忍び?) was a covert agent or mercenary of feudal Japan specialising in unorthodox arts of war. The functions of the ninja included espionage, sabotage, infiltration, and assassination, as well as open combat in certain situations. The ninja, using covert methods of waging war, were contrasted with the samurai, who had strict rules about honour and combat.
In his Buke Myōmokushō, military historian Hanawa Hokinoichi writes of the ninja:
“ They travelled in disguise to other territories to judge the situation of the enemy, they would inveigle their way into the midst of the enemy to discover gaps, and enter enemy castles to set them on fire, and carried out assassinations, arriving in secret. ”
The origin of the ninja is obscure and difficult to determine, but can be surmised to be around the 14th century. Few written records exist to detail the activities of the ninja. The word shinobi did not exist to describe a ninja-like agent until the 15th century, and it is unlikely that spies and mercenaries prior to this time were seen as a specialised group. In the unrest of the Sengoku period (15th - 17th centuries), mercenaries and spies for hire arose out of the Iga and Kōga regions of Japan, and it is from these clans that much of later knowledge regarding the ninja is inferred. Following the unification of Japan under the Tokugawa shogunate, the ninja descended again into obscurity. However, in the 17th and 18th centuries, manuals such as the Bansenshukai (1676) — often centred around Chinese military philosophy — appeared in significant numbers. These writings revealed an assortment of philosophies, religious beliefs, their application in warfare, as well as the espionage techniques that form the basis of the ninja's art. The word ninjutsu would later come to describe a wide variety of practices related to the ninja.
The mysterious nature of the ninja has long captured popular imagination in Japan, and later the rest of the world. Ninjas figure prominently in folklore and legend, and as a result it is often difficult to separate historical fact from myth. Some legendary abilities include invisibility, walking on water, and control over natural elements. The ninja is also prevalent in popular culture, appearing in many forms of entertainment media.