After the Treaty of Kępno in 1282, and the death of the last Samboride in 1294, the region was ruled by kings of Poland for a short period, although also claimed by Brandenburg. After the Teutonic takeover in 1308 the region was annexed to the monastic state of the Teutonic Knights. In the Second Peace of Thorn (1466) most of the region became part of Royal Prussia within the Kingdom of Poland, as it remained until being annexed by the Kingdom of Prussia in the partitions of 1772 and 1793.