<P> After the Genpei war, Yoritomo obtained the right to appoint shugo and jitō, and was allowed to organize soldiers and police, and to collect a certain amount of tax . Initially, their responsibility was restricted to arresting rebels and collecting needed army provisions and they were forbidden from interfering with Kokushi officials, but their responsibility gradually expanded . Thus, the samurai - class appeared as the political ruling power in Japan . </P> <P> Various samurai clans struggled for power during the Kamakura and Ashikaga shogunates . Zen Buddhism spread among the samurai in the 13th century and helped to shape their standards of conduct, particularly overcoming the fear of death and killing, but among the general populace Pure Land Buddhism was favored . </P> <P> In 1274, the Mongol - founded Yuan dynasty in China sent a force of some 40,000 men and 900 ships to invade Japan in northern Kyūshū . Japan mustered a mere 10,000 samurai to meet this threat . The invading army was harassed by major thunderstorms throughout the invasion, which aided the defenders by inflicting heavy casualties . The Yuan army was eventually recalled and the invasion was called off . The Mongol invaders used small bombs, which was likely the first appearance of bombs and gunpowder in Japan . </P> <P> The Japanese defenders recognized the possibility of a renewed invasion and began construction of a great stone barrier around Hakata Bay in 1276 . Completed in 1277, this wall stretched for 20 kilometers around the border of the bay . It would later serve as a strong defensive point against the Mongols . The Mongols attempted to settle matters in a diplomatic way from 1275 to 1279, but every envoy sent to Japan was executed . This set the stage for one of the most famous engagements in Japanese history . </P>

When did the samurai become important in japanese society