The only Edo Period castle town in northerly Hokkaidō, Matsumae was founded in the late 16th century by the Matsumae Clan, upon a directive from Toyotomi Hideyoshi. For long the lone Japanese outpost in what was a wild, remote and largely Ainu territory, the town was meant to function as a sort of defensive fiefdom against "the northern barbarians" (and later the Russians). The original Edo-period castle burnt down in a 1949 fire, but was rebuilt. Parts of the old town, most notably its former Tera-machi (including the Matsumae Clan graves) remain in the area north of the castle.