It was first mentioned in the beginning of the 14th century, as an outpost guarding the city of Pskov. Between 1431 and 1434, Pskovians built a fortress there, the remains of which can still be seen. It was attacked on numerous occasions by Swedes and Poles (e.g., during the Russo–Swedish War (1590–1595) and the Ingrian War), captured by Swedes in 1614, but was finally returned to Russia in 1617 according to the Treaty of Stolbovo.