The Oniwaban was an elite of ninja who were at guard of the Edo Castle during the Togukawa Era.
For hundreds of years the IGA (Togakure) group of ninja were the major force in Ninjitsu, however smaller groups existed in other parts of Japan. Within these groups of spies, saboteurs, and killers, another family incread its power, namely the deadly KOGA of Shiga prefecture.
Interestingly, Shiga is next to the Mie prefecture in southern Japan. So, the KOGA and IGA inhabited the same mountain range, in two valleys divided by a mountain.
During the centuries, several leaders such as Takeda Shingen, Oda Nobunga, and perhaps the greatest general in Japanese History, Tokugawa Ieyasu all employed the Ninja to help control the country through a complex spy network.
With the close of the Sengoku era in 1600, three hundred years of peace and prosperity followed, known as the Tokugawa era. Up until this time the capital of Japan had been in Kyoto, but Tokugawa moved the capital to Edo (Tokyo today). He took with him three hundred Ninja from the KOGA and IGA groups as personal bodyguards. So the 'Oniwaban' group of ninja set, not as an espionage unit, but as an internal security unit. Later these Ninja guarded the castle in Tokyo.
These are all the information I've been able to find. If you notice any error or have more information, please contact me by e-mail.^_^