A ninja (忍者; ɲiꜜɲdʑa) or shinobi (忍び; ɕinobi) was a covert agent, mercenary, or guerrilla warfare expert in feudal Japan. The functions of a ninja included siege and infiltration, ambush, reconnaissance, espionage, deception, and later bodyguarding and their fighting skills in martial arts, including ninjutsu. Their covert methods of waging irregular warfare were deemed dishonorable and beneath the honor of the samurai. Though shinobi proper, as specially trained warriors, spies, and mercenaries, appeared in the 15th century during the Sengoku period, antecedents may have existed as early as the 12th century.
In the unrest of the Sengoku period, jizamurai families, that is, elite peasant-warriors, in Iga Province and the adjacent Kōka District formed ikki - "revolts" or "leagues" - as a means of self-defense. They became known for their military activities in the nearby regions and sold their services as mercenaries and spies. It is from these areas that much of the knowledge regarding the ninja is drawn. Following the unification of Japan under the Tokugawa shogunate in the 17th century, the ninja faded into obscurity. A number of shinobi manuals, often based on Chinese military philosophy, were written in the 17th and 18th centuries, most notably the Bansenshūkai (1676).
By the time of the Meiji Restoration (1868), shinobi had become a topic of popular imagination and mystery in Japan. Ninja figured prominently in legend and folklore, where they were associated with legendary abilities such as invisibility, walking on water and control over natural elements. Much of their perception in popular culture is based on such legends and folklore, as opposed to the covert actors of the Sengoku period.
Ninja is the on'yomi (Early Middle Chinese–influenced) reading of the two kanji "忍者". In the native kun'yomi reading, it is pronounced shinobi, a shortened form of shinobi-no-mono (忍びの者).
The word shinobi appears in the written record as far back as the late 8th century in poems in the Man'yōshū.