Hokkaido was settled by Ainu, Nivkh, and Orok 20,000 years ago. The Nihon Shoki, finished in 720, is often said to be the first mention of Hokkaido in recorded history. According to the text, Abe no Hirafu led a large navy and army to northern areas from 658 to 660 and came into contact with the Mishihase and Emishi. One of the places Hirafu went to was called Watarishima which is often believed to be present-day Hokkaido. However, many theories exist in relation to the details of this event, including the location of Watarishima and the common belief that the Emishi in Watarishima were the ancestors of the present-day Ainu people.
During the Nara and Heian periods (710�1185), people in Hokkaido conducted trade with Dewa Province, an outpost of the Japanese central government. From the medieval ages, the people in Hokkaid? began to be called Ezo. Around the same time Hokkaid? came to be called Ezochi or Ezogashima. The Ezo mainly relied upon hunting and fishing and obtained rice and iron through trade with the Japanese.
During the Muromachi period (1336�1573), the Japanese created a settlement at the south of the Oshima peninsula. As more people moved to the settlement to avoid battles, disputes arose between the Japanese and the Ainu. The disputes eventually developed into a war. Takeda Nobuhiro killed the Ainu leader, Koshamain, and defeated the opposition in 1457. Nobuhiro's descendants became the rulers of the Matsumae-han, which was granted exclusive trading rights with the Ainu in the Azuchi-Momoyama and Edo periods (1568�1868). The Matsumae family's economy relied upon trade with the Ainu. They held authority over the south of Ezochi until the end of the Edo period in 1868.
The Matsumae clan rule over the Ainu must be understood in the context of the expansion of the Japanese feudal state. Medieval military leaders in northern Honsh? maintained only tenuous political and cultural ties to the imperial court and its proxies, the Kamakura