According to some scholars, Tarki sits on the site of Samandar, the capital of Khazaria until the early 8th century. In 1396, Timur passed through Tarki during the Tokhtamysh–Timur war. In the middle ages the Shamkhalate state is formed, lately becoming Shamkhalate of Tarki. Tarki had been the capital of the Kumyk state at least from the 16th century. This state was not abolished until 1867.