Porrentruy (French pronunciation: , Franc-Comtois: Poérreintru French pronunciation: , German: Pruntrut) is a Swiss municipality and seat of the district of the same name located in the canton of Jura.
 Porrentruy is home to National League team, HC Ajoie.
 The first trace of human presence in Porrentruy is a mesolithic tool that was found in the back yard of the Hôtel-Dieu.  Scattered, individual objects have also been found from the neolithic, the late Bronze Age and the Iron Age.  The first known settlement in what became Porrentruy goes back to the Roman era. In 1983, the ruins of a Gallo-Roman temple were discovered in the cemetery on the north of town, and Roman coins were found there.  Near the town, a kilometer long (0.6 mile) section of the Augst-Epomanduodurum (now Mandeure) Roman road was discovered.
 In the back yard of the Hôtel-Dieu the charred remains of a building from the 10th or 11th century were discovered.  However, the first historical mention of the name occurs in 1136 as Purrentru. The name presumably comes from the Latin pons Ragentrudis (Ragentrud bridge). Ragentrud was the wife of the Frankish King Dagobert I.: 231  The German form of the name, Pruntrut may have a separate etymology from Bruntrutum, which means an abundant spring.: 232 
 The first settlement was established in 1140 in the vicinity of Church of Saint-Germain, which was built in the Early Middle Ages. The Counts of Pfirt, who owned the region around Porrentruy, built a castle on a defensible hill and made it the capital of the Ajoie territory.  A settlement (now known as the Faubourg de France) was founded at the foot of the castle, with another south on the opposite hill.  The city wall was probably built before 1283 and surrounded the two settlements, but not the parish church of Saint-Germain.
 In 1236 the Counts of Pfirt pledged the town to the Counts of Montbéliard, however, they retained their rights to the Ajoie until 1281 when they sold the territory to the Bishop of Basel.  The Counts of Montbéliard refused to hand over Porrentruy, which led Bishop Henry of Isny to request support from King Rudolph I of Habsburg.  After six weeks under siege, the Count relented and handed it over to the Bishop.  On 20 April 1283, the king asked the Bishop of Basel to grant Porrentruy a town charter and make it a free Imperial city.  While the Counts of Montbéliard retained some power in the town, their influence waned during the 13th century.
 Financial difficulties forced the Bishop to sell the Ajoie (including Porrentruy) back to the lords of Montbéliard in 1386. But in 1461, the town once again became subject to the episcopal see.  Because of the Reformation in Basel, the Bishopric moved its official headquarters to Porrentruy in 1527. Under Bishop Jakob Christoph Blarer von Wartensee, who reigned from 1575 to 1608, the town reached the apogee of its importance. In his time, many architectural projects, including expansion of the castle and the building of a Jesuit college, were undertaken. This period of prosperity ended in 1618 with the outbreak of the Thirty Years' War. Porrentruy was repeatedly occupied, besieged, and plundered.
 The first parish church of Saint-Germain was replaced in the 13th century by a new building, which underwent several renovations.  The Church of Saint-Pierre was completed in 1349 and became the parish church in 1475.  The cathedral chapter was established in 1377.  Several religious orders were active in the city, including the Jesuits who built their college in 1591. In addition to the Jesuits other orders included the Ursulines (1619), the Sisters of the Annonciade (permanently established in 1646) and the Capuchins (1663).
 The first uprising against the Bishop's power was under the Comité de la Commune de Porrentruy on 20 August 1790, but they were unable to expel the Bishop.  However, on 27 April 1792, French Revolutionary troops invaded the city and drove the Bishop out.  Porrentruy became the capital of a dependent republic, which was then incorporated into France in 1793 as the Département du Mont-Terrible. In 1800, this department was incorporated into the Département du Haut-Rhin as a sub-département.  During the War of the Sixth Coalition against Napoleon, Allied troops entered Porrentruy on 24 December 1813.  Following their liberation, the future of this former episcopal seat was uncertain.  The government divided into two parties, the Episcopal party that sought the return of the prince bishop as the head of a Swiss canton, while the French party wanted to retain the current secular government.  However, soon after the fall of Napoleon, the municipality was given to the Canton of Bern (in 1815) to compensate for the loss of the Canton of Vaud, which had become a separate canton in 1803.
 Both factions, the religious and the secular, retained power in the town in the following years.  The political life in the 19th century was characterized by the severe conflict between Liberal-Radicals and the Catholic Conservatives.  The secular side gained power in 1860, when the mayor, Joseph Trouillat, was forced out of office.  The Radicals retained the mayor's office and a majority of the town council from 1860 until 1972.
 Until World War I, Porrentruy was the cultural center of the region and had a larger population than Delémont. However, with the increase in automobile traffic, its situation on the edge of the country became a liability and caused economic stagnation. In the second half of the 20th century, tensions between the French-speaking minority in the Canton of Bern and the German-speaking majority led to the creation of the new Canton of Jura on 1 January 1979. To the chagrin of the inhabitants of Ajoie, Delémont was chosen as the cantonal capital.
 Porrentruy is the site of many important institutions of the canton of Jura, including the cantonal courts, and also of the archives of the former Episcopal See of Basel. It is also the location of the Université Populaire Jurassienne.
 In 1988, Porrentruy was awarded the Wakker Prize for the development and preservation of its architectural heritage.
 Porrentruy has an area of 14.76 km2 (5.70 sq mi).  Of this area, 5.08 km2 (1.96 sq mi) or 34.4% is used for agricultural purposes, while 5.91 km2 (2.28 sq mi) or 40.1% is forested.   Of the rest of the land, 3.64 km2 (1.41 sq mi) or 24.7% is settled (buildings or roads), 0.12 km2 (30 acres) or 0.8% is either rivers or lakes and 0.03 km2 (7.4 acres) or 0.2% is unproductive land.
 Of the built up area, industrial buildings made up 1.7% of the total area while housing and buildings made up 10.7% and transportation infrastructure made up 7.3%.  Power and water infrastructure as well as other special developed areas made up 3.5% of the area while parks, green belts and sports fields made up 1.5%.  Out of the forested land, 38.8% of the total land area is heavily forested and 1.2% is covered with orchards or small clusters of trees.  Of the agricultural land, 22.0% is used for growing crops and  12.1% is pastures.  Of the water in the municipality, 0.2% is in lakes and 0.6% is in rivers and streams.
 The municipality lies on both sides of the Allaine River, in Ajoie (the bulge in the northwest corner of Switzerland that extends into France) at the foot of the Jura Mountains on the north. In addition to the wide valley of the Allaine itself, it includes the watershed of the Creux-Genat River, that flows down from the peaks of La Banné (511 m [1,677 ft]) and La Perche (526 m [1,726 ft]). In the north, the municipality includes the hills and forests of the Petit Fahy (543 m [1,781 ft]) und Grand Fahy (570 m [1,870 ft]). The highest point in the municipality is the ridge that divides it from the municipality of Bure at 580 m (1,900 ft).
 The blazon of the municipal coat of arms is Argent, a Boar salient Sable.
 Porrentruy has a population (as of December 2020) of 6,434.  As of 2008, 16.4% of the population are resident foreign nationals.  Over the last 10 years (2000–2010) the population has changed at a rate of -0.9%.  Migration accounted for 0.3%, while births and deaths accounted for -2.9%.
 Most of the population (as of 2000) speaks French (6,046 or 89.5%) as their first language, German is the second most common (191 or 2.8%) and Italian is the third (147 or 2.2%).  There are 2 people who speak Romansh.
 As of 2008, the population was 48.5% male and 51.5% female.  The population was made up of 2,655 Swiss men (39.9% of the population) and 573 (8.6%) non-Swiss men.  There were 2,895 Swiss women (43.5%) and 533 (8.0%) non-Swiss women.  Of the population in the municipality, 2,201 or about 32.6% were born in Porrentruy and lived there in 2000.  There were 2,066 or 30.6% who were born in the same canton, while 812 or 12.0% were born somewhere else in Switzerland, and 1,361 or 20.2% were born outside of Switzerland.
 As of 2000, children and teenagers (0–19 years old) make up 22% of the population, while adults (20–64 years old) make up 59.5% and seniors (over 64 years old) make up 18.5%.
 As of 2000, there were 2,770 people who were single and never married in the municipality.  There were 3,031 married individuals, 498 widows or widowers and 454 individuals who are divorced.
 As of 2000, there were 3,022 private households in the municipality, and an average of 2.1 persons per household.  There were 1,261 households that consist of only one person and 152 households with five or more people.  In 2000, a total of 2,921 apartments (84.5% of the total) were permanently occupied, while 259 apartments (7.5%) were seasonally occupied and 278 apartments (8.0%) were empty.  As of 2009, the construction rate of new housing units was 1.7 new units per 1000 residents.  The vacancy rate for the municipality, in 2010, was 2.25%.
 The historical population is given in the following chart:
 The Archives of the Republic and the Canton and the cantonal library, Porrentruy Castle, the church and college of the Jesuits, the St-Pierre Church, the Hôtel de Gléresse et Fondation des Archives, the Hôtel de Gléresse with the archives, the Hôtel-Dieu with the Pharmacy Museum and the Jura Natural Sciences Museum and gardens are listed as Swiss heritage site of national significance.  The entire old town of Porrentruy is part of the Inventory of Swiss Heritage Sites.
 The scenic historic city center has many buildings in gothic, baroque, and neo-classical styles, notably the buildings of the Jesuit college, which are now used by the cantonal school. The only remaining medieval city gate is the Porte de France, which was built in 1563.
 The Catholic Church of Saint-Pierre is a gothic basilica that was built from 1330 to 1350. It houses valuable relics and has a late-gothic altar. The Catholic Church of Saint-Germain, was built in the 13th century and restored and expanded in 1698. The chapel of the Jesuit college (1599–1603) has an octagonal tower built in 1701, which is now used as a concert hall. The church of the Ursulines was dedicated in 1626.
 On a prominence stands the Château de Porrentruy, which was the residence of the Bishop of Basel from 1527 to 1792. The oldest part is the round Bergfried, which was built in 1271.
 Important baroque buildings are the Hôtel de Ville (1761–63), the Hôtel-Dieu (1761–65), the Hôtel de Gléresse (built in 1750 for the Baron of Ligerz), and the Hôtel des Halles (1766–69). On the squares of the old city are monumental fountains, including the Fontaine des Samarites (1564) and the Fontaine Suisse (1518).
 In the 2007 federal election the most popular party was the PSS which received 37.11% of the vote.  The next three most popular parties were the PDC (29.88%), the PLR (14.89%) and the UDC (12.5%).  In the federal election, a total of 2,082 votes were cast, and the voter turnout was 45.2%.
 In the course of the 19th century, Porrentruy developed from a trading center to an important industrial town, with traditional industries such as watchmaking, shoemaking, and textiles. In the 20th century, other important industries were added, notably metalworking, machine manufacturing, electronics, and furniture building. Agriculture is no longer a major factor in the labor market of the municipality.
 As of  2010, Porrentruy had an unemployment rate of 6.3%.  As of 2008, there were 48 people employed in the primary economic sector and about 17 businesses involved in this sector.  1,933 people were employed in the secondary sector and there were 108 businesses in this sector.  3,734 people were employed in the tertiary sector, with 407 businesses in this sector.  There were 3,308 residents of the municipality who were employed in some capacity, of which females made up 44.0% of the workforce.
 In 2008 the total number of full-time equivalent jobs was 4,822.  The number of jobs in the primary sector was 34, all of which were in agriculture.  The number of jobs in the secondary sector was 1,887 of which 1,454 or (77.1%) were in manufacturing and 389 (20.6%) were in construction.  The number of jobs in the tertiary sector was 2,901.  In the tertiary sector; 612 or 21.1% were in wholesale or retail sales or the repair of motor vehicles, 65 or 2.2% were in the movement and storage of goods, 133 or 4.6% were in a hotel or restaurant, 22 or 0.8% were in the information industry, 163 or 5.6% were the insurance or financial industry, 220 or 7.6% were technical professionals or scientists, 340 or 11.7% were in education and 834 or 28.7% were in health care.
 In 2000, there were 4,145 workers who commuted into the municipality and 1,051 workers who commuted away.  The municipality is a net importer of workers, with about 3.9 workers entering the municipality for every one leaving.  About 18.3% of the workforce coming into Porrentruy are coming from outside Switzerland, while 0.5% of the locals commute out of Switzerland for work.  Of the working population, 8.9% used public transportation to get to work, and 57.3% used a private car.
 From the 2000 census, 5,017 or 74.3% were Roman Catholic, while 657 or 9.7% belonged to the Swiss Reformed Church.  Of the rest of the population, there were 45 members of an Orthodox church (or about 0.67% of the population), there were 2 individuals (or about 0.03% of the population) who belonged to the Christian Catholic Church, and there were 107 individuals (or about 1.58% of the population) who belonged to another Christian church.  There were 3 individuals (or about 0.04% of the population) who were Jewish, and 160 (or about 2.37% of the population) who were Muslim.  There were 14 individuals who were Buddhist, 4 individuals who were Hindu and 4 individuals who belonged to another church.  481 (or about 7.12% of the population) belonged to no church, are agnostic or atheist, and 312 individuals (or about 4.62% of the population) did not answer the question.
 In Porrentruy about 2,097 or (31.1%) of the population have completed non-mandatory upper secondary education, and 813 or (12.0%) have completed additional higher education (either university or a Fachhochschule).  Of the 813 who completed tertiary schooling, 59.5% were Swiss men, 25.2% were Swiss women, 8.4% were non-Swiss men and 6.9% were non-Swiss women.
 The Canton of Jura school system provides two year of non-obligatory Kindergarten, followed by six years of primary school.  This is followed by three years of obligatory lower secondary school where the students are separated according to ability and aptitude.  Following the lower secondary stage, students may attend a three or four year optional upper secondary school followed by some form of tertiary school or they may enter an apprenticeship.
 During the 2009–10 school year, there were a total of 1,183 students attending 59 classes in Porrentruy.  There were 5 kindergarten classes with a total of 83 students in the municipality.  The municipality had 18 primary classes and 342 students.  During the same year, there were 36 lower secondary classes with a total of 758 students.
 As of 2000, there were 1,682 students in Porrentruy who came from another municipality, while 52 residents attended schools outside the municipality.
 Porrentruy is home to the Bibliothèque cantonale jurassienne library.  The library has (as of 2008) 115,585 books or other media, and loaned out 10,097 items in the same year.  It was open a total of 243 days with average of 32 hours per week during that year.
 Porrentruy is also home to the only two tertiary schools (or "Lycées" in French) in the Canton of Jura. The first being the Lycée Cantonal de Porrentruy, a public tertiary school and the second being the Collège et Lycée Saint-Charles.
 Porrentruy lies at the junction of two railway lines: the Delémont–Delle railway line of Swiss Federal Railways and the Porrentruy–Bonfol railway line of Chemins de fer du Jura. The first railway line opened in 1872, connecting Porrentruy with Delle, in France, via Boncourt. A further connection south to Glovelier and the rest of the Swiss railway network opened in 1877. The branch line to Bonfol opened in 1901.
 The municipality lies on the first stretch of the motorway (A16 or E27) to open (in 1998) in the canton of Jura between Delémont and Belfort, France. The motorway is meant to be completed in 2016, the difficult topography of the Jura only allowing the opening of short sections, one by one. This explains why the international railway played such an important role in the economic rise of Porrentruy because the railway follows the course of the Allaine river to the economic rail hub at Belfort.