I do not take ninjitsu, so I might be wrong, but here is the information I have gathered on what ninja may have been. Remember reading Japanese/Samurai history is like reading Sicilian mafioso history.
During fuedal Japan there were Samaria as everyone knows. The Mongols tried to invade japan, and every Samurai got together to stop them. This made a lot of families poor, as they had to pay for their own equipment. It was tradition that the winner would take the spoils, however there were none. Since this was the first time the Samurai from all of Japan had joined together, The Bakufu decided that he would let these poor people keep their land, and write off all of their debts and taxes, but this actually made it worse. Noone would lend them any cash thinking the government would just write it off again.
These samurai needed money so they started working for the temples and local warlords. Temples used to war against each other, and the emperor to gain wealth. The temples had tons of cash and hired bodyguards called the Sohei (warrior monks). These guys were mostly temple employees and refugees, not really monks. This was late Heian period. there was also another goup or sectarians called the Yamabushi. Followers of En-no-gyoja. They were a buddhist sect that lived in seclusion in the mountian ranges, and travelled mountianous routes all over Japan. Because they offered a means of underground communication they were hired by provincial warlords (Not the Shogun as said earlier) and acted as couriers. Some of the Yamabushi became professional spies known as ninja. Neither sohei nor yamabushi were considered samurai, eventhough some later became samurai.
taken from here
http://www.onmarkproductions.com/htm...d-shrines.html
The yamabushi (ninja) did not begin to exist until ~700ad. It wasn't until probably late 1500s that yamabushi became warriors...ninja as we think of them today.