The town was the capital of the Duchy of Teschen since 1290, which was ruled by Piast dynasty until 1653 and by the Habsburg Dynasty of Austria until 1918. It was in Teschen that Maria Theresa and Frederick II on in May 1779 signed the Teschen Peace Treaty, which put an end to the War of the Bavarian Succession. In the 19th century Teschen was known for its ethnic, religious and cultural diversity, containing mostly German, Polish, Jewish and Czech communities. There was also a small Hungarian community in the town consisting mostly of officers and clerks.