The ninjas' use of guerrilla tactics against better-armed enemy samurai does not mean that they were limited to espionage and undercover work; that is simply where their actions most notably differed from the more accepted tactics of samurai. Their weapons and tactics were partially derived from the need to conceal or defend themselves quickly from Samurai, which can be seen from the similarities between many of their weapons and various sickles and threshing tools used at the time. [1].
Ninja as a group first began to be written about in 15th century feudal Japan as martial organizations predominately in the regions of Iga and Kouga of central Japan, though the practice of guerrilla warfare and undercover espionage operations goes back much further.
At this time, the conflicts between the clans of daimyo that controlled small regions of land had established guerrilla warfare and assassination as a valuable alternative to frontal assault. Since Bushido, the Samurai Code, forbade such tactics as dishonorable, a daimyo could not expect his own troops to perform the tasks required; thus, he had to buy or broker the assistance of ninja to perform selective strikes, espionage, assassination, and infiltration of enemy strongholds (Turnbull 2003).
There are a few people and groups of people regarded as having been potential historical ninja from approximately the same time period. It is rumored that some of the higher-ranking daimyos and shoguns were in fact ninja, and exploited their role as ninja-hunters to deflect suspicion and obscure their participation in the 'dishonorable' ninja methods and training.
Though typically classified as assassins, many of the ninja were warriors in all senses. In Hayes's book, Mystic Arts of the Ninja, Hattori Hanzo, one of the most well-known ninja, is depicted in armor similar to that of a Samurai. Hayes also says that those who ended up recording the history of the ninja were typically those within positions of power in the military dictatorships, and that students of history should realize that the history of the ninja was kept by observers writing about their activities as seen from the outside.
“Ninjutsu did not come into being as a specific well defined art in the first place, and many centuries passed before ninjutsu was established as an independent system of knowledge in its own right. Ninjutsu developed as a highly illegal counter culture to the ruling Samurai elite, and for this reason alone, the origins of the art were shrouded by centuries of mystery, concealment, and deliberate confusion of history” The Historical Ninja. –By Soke Masaaki Hatsumi
A similar account is given by 10th Dan instructor Stephan K. Hayes – “The predecessors of Japan's’ ninja were so called rebels favoring Buddhism who fled into the mountains near Kyoto as early as the 7th century A.D. to escape religious persecution and death at the hands of imperial forces” Ninjutsu: The Art of Invisibility