Schaffhausen had been a city-state in the Middle Ages, documented to have struck its own coins from 1045.
In about 1050, the counts of Nellenburg had founded the Benedictine monastery of All Saints, which became the center of the town.
Perhaps as early as 1190, certainly in 1208, it was an imperial free city, while the first seal dates from 1253.
The powers of the abbot had gradually been limited and in 1277 the Emperor Rudolf I gave the town a charter of liberties.
In 1330 the emperor Louis of Bavaria pledged it to the Habsburgs.
In the early fifteenh century, Habsburg power over the city waned.
By 1411 the guilds ruled the city.
Then, in 1415 the Habsburg Duke Frederick IV of Austria sided with the Antipope John XXIII at the Council of Constance, and was banned by the Emperor Sigismund.
As a result of the ban and Frederick's need of money, Schaffhausen is able to buy its independence from the Habsburgs in 1418.
The city allies with six of the Swiss confederates in 1454 and allies with a further two (Uri and Unterwalden) in 1479.
Schaffhausen becomse a full member of the Old Swiss Confederacy in 1501.