In 1691, it became the seat of the Bishop's bailiff over the surrounding area. The bailiff's castle was built around the end of the 17th century. After the French invasion (1793–1813), Saignelégier was the capital of the canton in the Département of Mont-Terrible and then in the Département of Haut-Rhin. Following the collapse of Napoleonic France, in 1815 it became part of the Canton of Bern, where it remained until the founding of the Canton of Jura in 1978.