Obanyaku was the post assigned to samurai from non-capital areas to maintain the security of Kyoto during the later Heian to early Muromachi period or to maintain the security of Kamakura city during the Kamakura period.
When Goseibai-shikimoku (code of conduct for samurai) was establshed during the Kamakura period, it was explicitly written in Taibon sankajo (three basic rights of shugo, provincial constable) that obanyaku was a post to be assumed by gokenin (an immediate vassal of the shogunate in the Kamakura and Muromachi through Edo periods). During the Kamakura and later periods, the post was assigned to each province, and shogo in each province was responsible for selecting the gokenin to assume the post in the province (oban saisoku). In the period of the Northern and Southern Courts (Japan), it became almost extinct.
The post to guard the palace and the residences of special imperial family members (and later those of the Fujiwara clan) in Kyoto was called Kyoto Obanyaku. With the length of the duty being three years during the Heian period, it was a large burden on samurai in non-capital regions, and MINAMOTO no Yoritomo reduced it to half a year, being further reduced to three months in the middle of the Kamakura period when the samurai side became more influential than the kuge (court noble) side.
However, towards the end of the Heian period, it gave a chance fo samurai from non-capital provinces to gain a connection with kuge in the capital, and some samurai could obtain an official rank through their connections. In other words, there was the following merit in assuming the post: A person at the obanyaku post could be assigned to the post of suke (provisional governor), gon-no-suke (provisional vice governor) or jo (secretary of provincial offices) in his original province, gaining a position in the imperial court and having his control right backed by the authority of the imperial court.
Also, some at the post learned culture in the capital, such as making waka poems and brought it back to their original provinces
There were also some demerits: For example, the post of obanyaku was sometimes assumed not by the head of a clan but by his son, and in such a case, when the head of the clan died while his son was in Kyoto, it sometimes happened that the postion of head was deprived of by his younger brother or his uncle (an example: Hirotsune KAZUSA). In addition, it also happened that, while a father, the head of a clan, was in Kyoto and his son in his original province, the father could not speedily handle disturbances that occurred in the province (an example: Shigetada HATAKEYAMA).
The post for guarding the bakufu (Japanese feudal government headed by a shogun) in Kamakura was called Kamakura obanyaku. It is concerned with the service of favors and services. In the feaudal system based on favors and services, it became a natural post for the gokenin who served the bakufu.