Schaffhausen was a city state in the Middle Ages, documented to have struck its own coins from 1045. About 1050 the counts of Nellenburg founded the Benedictine monastery of All Saints, which became the centre 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 were gradually 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 15th 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 was able to buy its independence from the Habsburgs in 1418. The city allied with six of the Swiss confederates in 1454 and allied with a further two (Uri and Unterwalden) in 1479. Schaffhausen became a full member of the Old Swiss Confederacy in 1501.
The Reformation was adopted, initially, in 1524 and completely in 1529. The town was heavily damaged during the Thirty Years’ War by the passage of Swedish (Protestant) and Bavarian (Roman Catholic) troops and the very important bridge was burnt down. It was not until the early 19th century that the arrested industrial development of the town recommenced. In 1857, the first railroad, the Rheinfallbahn, running from Winterthur, reached Schaffhausen.