The city was an Ainu habitation, and the name "Otaru" is recognised as being of Ainu origin, possibly meaning "River running through the sandy beach". The very small remaining part of the Temiya Cave contains carvings from the Zoku-Jōmon period of Ainu history, around A.D. 400. Otaru was recognised as a village by the bakufu in 1865, and in 1880 the first railway line in Hokkaido was opened with daily service between Otaru and Sapporo.