After losing its status as a free imperial city within the Holy Roman Empire in 1654 the City of Besançon refused to recognise the sovereignty of a new protector, whether the king of France or Spain, until Louis XIV dissolved the municipal government in 1676. The government comprised only a tiny area around the City of Besançon in the Franche-Comté, which meant that it had limited independence although it had considerable internal autonomy and still tried to claim neutrality.
Besançon became part of the Holy Roman Empire in 1034 as the Archbishopric of Besançon, and in 1184 it gained autonomy as a free imperial city under Frederick I, Holy Roman Emperor. The town slowly sought the protection of a number of outside protectors, or captains, such as Philip the Good, Duke of Burgundy. After the marriage of Mary of Burgundy to Maximilian I, Holy Roman Emperor in 1477, the city treated the Habsburgs as its protectors.
When Franche-Comté passed to Philip II of Spain in 1555, Besançon remained a free imperial city.
The city lost its status as a free city in 1651 as a reparation for other losses that the Spanish had suffered in the Thirty Years' War. After some resistance, this was finally confirmed by Besançon in 1654, although the city kept a high degree of internal autonomy.
In 1667 Louis XIV claimed Franche-Comté as a consequence of his marriage to Marie-Thérèse of Spain. As part of the War of Devolution, French troops arrived in the area in 1688. The town authorities tried to argue that it was neutral in any hostilities as it was an Imperial City, something that the French commander, the Prince de Conde, rejected as archaic. The French agreed to very generous surrender terms with the town authorities, which included transferring the university from the then still recalcitrant Dole. There were also rumours that the regional Parlement may be transferred from Dole. The City also laid down that it would be left the relic of a fragment of the holy winding sheet, and that Protestants should not have liberty of conscience in the same way as they then had in the rest of France.
While the city was in French hands, the famed military engineer Sébastien Le Prestre de Vauban visited Besançon and drew up plans for its fortification. The Treaty of Aix-la-Chapelle returned the city to Spain within a matter of months, in return for the town of Frankenthal.
The Spaniards built the main centre point of the city's defences, "la Citadelle", siting it on Mont St. Etiene, which closes the neck of the bend in the river that encloses the old city. In their construction, they followed Vauban's designs.
From this time onwards, a large pro-French faction grew among some of the city.
The city was to finally lose its autonomy as a result of the Franco-Dutch War starting in 1672, where the Habsburgs took the side of the Dutch and so were to lose control of Franche-Comté and Besançon. After a siege of the city, French troops occupied the city in 1674, although they agreed to allow Besançon to keep its privileges.
In 1676 the French authorities wound up the magistracy, the democratic form of government of Besançon, on the instructions of Louis XIV. A baillarge court was set up in its stead. As compensation for losing its self-government, the city became the administrative centre for Franche-Comté, with the Parlement of Besançon administering the area, replacing the Parlement of Dôle. French control was confirmed in 1678 by the Treaty of Nijmegen.
Unlike most Free Imperial Cities which gradually became oligarchies, Besançon had a reasonably democratic form of government. The government consisted of 28 councillors elected every year by the seven parishes. These, in turn, chose 14 governors, who dealt with the day-to-day business. The main business was dealt with by both councillors and governors sitting together. There was also a provision for a general assembly of citizens in very important cases.
The protector — first the Dukes of Burgundy and then the Austrian and Spanish Habsburgs, and for two years the King of France — had the right to appoint a president for the governors and the commander of the soldiers who guarded the ramparts. The protector was never recognised as sovereign.