Mugaku Sogen was born in 1226 in south Song (during the Song Dynasty; 1127-1279) and became a priest at age 11. He entered the priesthood at Ching-tz’u-ssu temple when he was just 13 years old, and soon afterward, in 1239, he visited Wu-chun Shih-fan, under whom he studied the Zen teachings. In order to further his studies of Zen, he met with many different teachers. In 1279, he was invited to spread Zen in Japan by Hojo Tokimune, the eighth regent of the Kakamura Shogunate. Once in Japan, he lived at Kenchō-ji temple in Kamakura with Tokimune’s support. In 1282, when Hōjō Tokimune built Engaku-ji temple in Kamakura, he invited Sogen to be the founding priest. Two years later, Sogen returned to Kenchō-ji temple where he died. He exerted great spiritual influence on the leaders and warriors of Kamakura.
In 1275, Yuan soldiers attacked the temple where Sogen stayed. As the attack progressed, the priests present at the temple fled to safety. Sogen, however, chose to stay behind. According to legend, Sogen sat quietly on the floor in front of the temples main Buddha statue. As one of the Yuan soldiers unsheathed his sword to kill Sogen, Sogen recited a Buddhist precept. “I did a comprehensive study to seek the real universe, and finally got the answer. That is to say, all is vanity. People are vanity, and even Buddha’s teachings are vanity. Now, I am spiritually awakened, and so, even if you want to kill me with your huge sword, I don’t mind. I already know that I am vanity. This means when you swing your sword, you will just cut through a spring wind.” The soldier could not bring himself to kill Sogen, and expressed his respect for him, then turned and left Sogen in peace.
Faced with the strong possibility of war with the invasion on the Yuan Dynasty, Hojo Tokimune seized rule as the main decision maker of the then ruling Kakamura Shogunate. He became responsible for leading the resistance to the Mongol invaders. He built an army with the support of other Samurai, regulated internal conditions under his military control, and formed stone bulwarks to keep out the enemy. Despite the painstaking preparations Tokimune had in place, he found himself mentally and spiritually unaligned. At that time, he was already under the spiritual guidance of Mugaku Sogen.
Tokimune asked Mugaku Sogen, his Zen master also known as Bukko, for advice. Bukko replied he had to sit in meditation to find the source of his cowardice in himself. When Tokimune returned from meditation, Bukko said to him: "Finally there is the greatest event of my life." and asked, "How do you plan to face it?" Tokimune shouted "Katsu!" ("Victory!") as if he wanted to scare all the enemies in front of him. Mugaku responded with satisfaction: "It is true that the son of a lion roars as a lion!"
Later before the second Mongol invasion Tokimune invited him to Kencho-ji Temple from across the sea in 1279, and then often visited him at Kencho-ji. One day during their ongoing conversations, Mugaku Shogen took up his pen and wrote one word for Tokimune: Baku-bon-no (莫煩悩). His meaning and nuance was: “After you finish preparing for something (the battle), don’t worry too much. Over-thinking will only make you crazy. It won't help you at all. Your agony is produced by your own mind”
Receiving these words, Tokimune felt ready to face his enemy. He later went on to lead the Japanese to victory.
After Tokimune successfully repelled a Mongolian-Korean invasion from 1274 to 1281, He commissioned a temple to be built. As a strong follower of the teachings of Zen, Tokimune had planned the construction of the temple to serve as a memorial for the dead from both sides of the conflict. It was to become the resting place of their souls. The temple was also intended to serve as a centre from which the influence of Zen could be spread. Tokimune wanted other samurai to learn how to employ the teachings of Zen Buddhism to face their problems, as he had learned through Sogen. And so, he appointed Mugaku Sogen chief priest of Engaku-ji.