Beginning in the 13th century it was the border of Medieval Livonia and the Novgorod Republic.[6] Though in earlier periods Narva was part of a larger buffer zone between the two territories, gradually the river emerged as the exact border.[6] Castles built on the river banks (Narva Hermann Castle, founded at the beginning of the 14th century, Ivangorod fortress, established in 1492 and Vasknarva Castle, first built in the 14th century) were one of the main reasons behind this. Treaties from the 15th century between the Livonian Order and Novgorod Republic, later Tsardom of Russia, also recognize the Narva as the border.[6] In XVII century during the time of Swedish Estonia, when Ingria was also part of Sweden, the importance of the river as a border diminished. During the Russian Empire, from the end of the Great Northern War until the establishment of the Republic of Estonia in 1918, the Narva was the border of Governorate of Estonia and Saint Petersburg Governorate, with the exception of the town of Narva, which was part of the latter.