In 1224 after partition of Tālava trade roads along the Gauja river became property of Livonian Brothers of the Sword who erected a castle which is today known as Valmiera Castle. After the Battle of Saule in 1236 Valmiera Castle and nearby lands became the property of the newly established Livonian Order.