Buddhist monks introduced Zen teachings to Japan in the 12th century and they quickly spread throughout the country. Samurai were one of the early adopters of this religious and philosophical tradition and used its guiding principles of finding inner peace and enlightenment to strengthen themselves both on and off the battlefield.
A great deal of samurai thought was based on the teachings of Zen Buddhism, particularly the necessity of finding inner calm. Samurai followed a code called Bushido which taught followers to embrace the possibility of death at any moment. This principle partly came from Zen Buddhism which emphasizes the necessary impermanence of all material bodies. Zen Buddhism also taught samurai practitioners to clear their minds of all thoughts before battle, helping them overcome fear and distraction.
The primary reason samurai adopted Zen Buddhism was the belief that it strengthened them on the battlefield. They believed that plans and strategy on the battlefield led to death, and Zen helped followers dismiss such thoughts. Samurai, however, also embraced death and a disciplined samurai used zen meditation to confront the possible sensations of violent injuries daily. Zen philosophy also emphasizes mastering crafts and techniques by unifying body and mind through action without thought, which helped samurai master sword fighting, archery and other essential battle skills.
Samurai weren't simply warriors, they were an elite class in the Japanese medieval period, and the influence of Zen thought -- particularly with regard to virtues such as competence and composure -- was evident in many of the other activities they pursued off the battlefield. Samurai composed poetry, practiced the tea ceremony and maintained gardens. In all of these pursuits, the Zen practice of a clear, focused mind helped the samurai achieve high levels of mastery.
Stephen Turnbull, in his book "The Samurai and the Sacred" argues that Samurai did not exclusively use Zen Buddhism to form their moral code, and that it, instead, provided a method of intellectualizing several preexisting samurai beliefs. Buddhism as a whole played a large part in shaping samurai morality, but no single sect like Zen, was pervasive enough to dictate customs and practices. Some non-Buddhist belief systems, like Confucianism, even played an important part in ascribing virtues like self-discipline to the samurai mind.