The predecessors of oniwaban were officials called kusurigomeyaku (gunpowder charger) in Kishu domain where Yoshimune was the lord before becoming shogun.
御庭番の前身は、吉宗が将軍就任前に藩主を務めていた紀州藩お抱えの薬込役と呼ばれる役人たちであった。