Viljandi (German: Fellin) is a town and municipality in southern Estonia with a population of 19,150 (2011). It is the capital of Viljandi County. The town was first mentioned in 1283, upon being granted its town charter by Wilhelm von Endorpe. In 1211 the hill-fort of the Estonians in Viljandi was besieged by a joint army of Germans, Latvians, and Livs. The Livonian Sword Brethren captured the hill-fort in August 1223 from a contingent of the people of Rus, who joined forces with the insurgent Estonians. The following year the Grand Master Volquin led the construction of the castle at the site of the former hill-fort. The Viljandi (Fellin) castle was one of the largest in the Baltic region. It was a major fortification of the Livonian Order and was appointed a commander from 1248. The fortress was continually rebuilt and modernized over the next two-hundred years. In 1283, the town received a charter from Wilhelm von Endorpe, the master of the Order. The town became a member of the Hanseatic League at the beginning of the 14th century, and is one of five Estonian towns and cities in the league. In 1470, Johann Wolthus von Herse, then master of the order, took up residence in the castle. In 1481, Ivan III of Russia laid siege to the castle but could not take it. However, during the Livonian War, Muscovite Russia succeeded in seizing it in 1560. During the PolishSwedish War at the beginning of the 17th century the castle changed hands several times and fell into ruins. The same goes for the town, which was deprived of its privileges.