In 1360 the town was granted a charter as well as the rights to hold a market and enroll citizens. This charter, granted by Charles IV, was given to Gottfried von Hünenberg as the ruler of the city. The Habsburgs, attempting to maintain their influence in the region following the loss of Zug to the Swiss Confederation in 1364, bought part of the town in 1366 and completely bought the Hünenberg family out in 1370. However, following the decisive Habsburg defeat in the Battle of Sempach in 1386, Cham was taken by Zug and Schwyz. The Habsburgs had pawned the town to a citizen of Zürich, Götz Mülner, and so Zug was not able to completely own the city until the loan was repaid in 1415. The city would remain under the control of the vogt or bailiff of Zug until the French invasion of 1798.
