1814 the town and the surrounding valley transferred from Lausanne to the Diocese of Basel. Catholic church services resumed in Saint-Imier in 1857 and in 1866 the neo-gothic Church of St. Martin was built. In 1912 a Christian Catholic church was built in the town. In 1792 Théodore Frédéric Louis Liomin, the vogt or bailiff of Saint-Imier, threw his support behind the revolutionary movement that was sweeping the region. After the 1797 French victory and the Treaty of Campo Formio, Saint-Imier became part of the French Département of Mont-Terrible. Three years later, in 1800 it became part of the Département of Haut-Rhin. After Napoleon's defeat and the Congress of Vienna, Saint-Imier was assigned to the Canton of Bern in 1815. During the 19th century the anti-authoritarian or anarchist movement gained a foothold in the region. In 1872, the Jura Federation, which had strong support in Saint-Imier, organized a congress in Saint-Imier at which the Anti-authoritarian International Workingmen's Association or Anti-authoritarian International was founded. During the 18th century the inhabitants of the valley gradually gave up agriculture in favor of more lucrative jobs in the watch and lace-making industries. The first watch parts workshop opened in the 1720s and the industry continued to expand throughout the 19th century. By 1817 there were about 200 workers employed in either watchmaking workshops or small shops at home. The small scale workshops were replaced by large factory work, when Longines opened a factory in the town in 1867. By the end of the year, 1,600 people were employed in 47 watchmaking companies. Because the town's economy was so dependent on watchmaking, the economic crisis of the 1930s and the 1970s hit Saint-Imier hard. By the beginning of the 21st century, there were about ten watchmaking companies and the economy had diversified to include dental and medical technology and meteorology. Portions of the town were destroyed by fire in 1839, 1843 and 1856. A hospital opened in Saint-Imier in 1856. In 1874 the town was connected to the Swiss rail network. The town's infrastructure was modernized early, before 1900 it had municipal water, gas and electricity. Saint-Imier has grown into a regional education center. The town's secondary school opened in 1860, followed by a watchmaker's school in 1866. The watch-maker's school was expanded into a machinist's school in 1896 and a technical vocational school in 1961. In 1976 it became a school of engineering and