Samurai were paid by their feudal lords, the Daimyo, in rice or land. As Japan became more peaceful and the need for warriors decreased, many samurai moved into administrative positions or became tradesmen.
Samurai, who were in the service of feudal lords, were paid in units of rice called koku. One koku was equivalent to the amount of rice needed to feed a man for one year. Sometimes they were paid in gold coins called ryo, one ryo being equivalent to one koku.
The amount of rice a piece of land could produce was also measured in koku. The land would be worked by a lord's peasants. Some of the rice produced was collected as tax, while some was distributed to the lord's samurai as a stipend. The rice could be traded for coins so that the samurai could purchase goods and services from the merchant class. Some samurai were given land in return for their loyalty, giving them the ability to grow their own food and generate wealth.
After the Meiji Restoration, when feudalism was abolished and samurai were no longer allowed to carry swords, the samurai class became bureaucrats, farmers or tradesmen to make up for the lost income.