[2] It was built as an outpost for the Livonian order, mainly to strengthen the eastern border of Livonia and guard trade routes from Russia.
At the start of the Livonian War in 1558, German troops attacked Krasnij Gorodok and destroyed a number of parishes in Pskov.
In the same year Moscovian troops of Grigoriy Temkin occupied the castle, but suffering defeat, he was forced to abandon his conquest.
In 1577 Livonia was once again invaded by Russian troops under the guidance of Ivan IV Vasilyevich and the castle was sacked.
In the Russo-Polish War of 1654–1667 in 1654 the Russian voivod Lev Saltikov surrounded Ludza and the castle surrendered.