It is widely accepted that first Human habitation in the Japanese archipelago traced back to prehistoric times. The Jōmon period, named after its "cord-marked" pottery, was followed by the Yayoi in the first millennium BC, when new technologies were introduced from continental Asia. During this period, in the first century AD, the first known written reference to Japan was recorded in the Chinese Book of Han. Between the fourth century and the ninth century, Japan's many kingdoms and tribes gradually came to be unified under a centralized government, nominally controlled by the Emperor. The imperial dynasty established at this time continues to reign over Japan to this day. In 794, a new imperial capital was established at Heian-kyō (modern Kyoto), marking the beginning of the Heian period, which lasted until 1185. The Heian period is considered a golden age of classical Japanese culture. Japanese religious life from this time and onwards was a mix of Buddhism, and native religious practices known as Shinto.
Over the following centuries the power of the Emperor and the imperial court gradually declined and passed to the military clans and their armies of samurai warriors. The Minamoto clan under Minamoto no Yoritomo emerged victorious from the Genpei War of 1180–85. After seizing power, Yoritomo set up his capital in Kamakura and took the title of shogun. In 1274 and 1281, the Kamakura shogunate withstood two Mongol invasions, but in 1333 it was toppled by a rival claimant to the shogunate, ushering in the Muromachi period. During the Muromachi period regional warlords called daimyōs grew in power at the expense of the shogun. Eventually, Japan descended into a period of civil war. Over the course of the late sixteenth century, Japan was reunified under the leadership of the daimyō Oda Nobunaga and his successor Toyotomi Hideyoshi. After Hideyoshi's death in 1598, Tokugawa Ieyasu came to power and was appointed shogun by the Emperor. The Tokugawa shogunate, which governed from Edo (modern Tokyo), presided over a prosperous and peaceful era known as the Edo period (1600–1868). The Tokugawa shogunate imposed a strict class system on Japanese society and cut off almost all contact with the outside world.