The town was first mentioned in 1279, when, as the capital of the Grand Duke Traidenis, it was besieged by the Teutonic Knights. In 1390, during the Lithuanian Civil War (1389–1392), the knights burned the town and its buildings in the Pajauta valley, including the castle. After this raid, the town wasn't rebuilt, and the remaining residents moved to the top of the hill instead of staying in the valley.