Actually, there were two invasions.

In November of 1274, Kublai Khan, grandson of Genghis Khan and ruler of China, having already conquered all of mainland southeast Asia, sent an invasion force of approximately 40,000 Mongol, Korean, and Chinese troops to conquer Japan. The invasion caught the Japanese off-guard and unprepared, but bad weather forced the fleet to turn back after only a short stay in Japan, during which the Mongols ravaged a few seaside villages. For the next several years Kublai Khan was distracted by internal affairs, but he never gave up his dream of ruling Japan.

Seven years later he dispatched a second invasion, a massive armada consisting of 4,400 ships and 142,000 men, one of the largest forces ever assembled in recorded history. This time, however, the Japanese were ready. In the spring of 1281, when an expeditionary force of 42,000 men landed at Hakata bay in northern Kyushu, they were met by a well prepared Japanese force holding fortified positions. However, the Japanese soon realized that they were overmatched. While the samurai fought as individuals, the Mongols employed sophisticated battle formations. Mongol bows could shoot twice as far as Japanese bows, and the Mongols made use of crude explosives, which the Japanese had never faced. Skirmishes raged for a month, but despite inflicting heavy losses, the Mongols were unable to make any headway because of the heavy Japanese fortifications.

In July the Mongols put to sea again to join up with the main force of 100,000 men, which had been delayed in China for two months. Deciding to avoid the Hakata bay fortifications, the two fleets met off Takashima, 50 miles to the southwest, and prepared to carry out their invasion. Meanwhile, the Hojo shogunate, realizing the reality of the grim situation, had persuaded the emperor to order all the shrines in Japan to pray for divine intervention. Suddenly, as the Mongols were setting up a base camp at Takashima, a massive typhoon appeared out of nowhere and struck the Mongol fleet, sinking or beaching most of the ships and killing over 100,000 of the Mongol troops. According to legend, the storm struck on exactly the same day that ex-emperor Kameyama personally led a massive prayer to the sun-goddess Amaterasu, beseeching her to save his people. The storm was called the Kamikaze or "Divine Wind," and came to be seen as not just a fortuitous event, but as proof that Japan was a land favored by the gods.