The city was first separated from the governance of the County of Burgundy in 1034 as a prince-bishopric, an ecclesiastical state in the Holy Roman Empire.
[citation needed] Previous bishops, such as St Hugh I, had been referred to as princes of the Empire.
[4] After the marriage of Mary of Burgundy to Maximilian I, Holy Roman Emperor in 1477, the city was in effect a Habsburg fief.
In 1575, following the death of Charles IX of France, Huguenots attempted to capture Besançon in order to make it a stronghold, which meant that the city had to accept a Spanish garrison for protection - an important decline in its independent status.
It remained formally a portion of the Empire until its cession from Austria to Spain, along with Franche-Comté, in the peace of Westphalia in 1648.
Besançon tried to argue that it was neutral in any hostilities as it was a Free Imperial City of the Holy Roman Empire, something that the French commander the Prince de Conde rejected as archaic.
[7] The French agreed to very generous surrender terms with the town authorities which included transferring the university from the then still recalcitrant Dole.
The City also laid down that they 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.
[9] While it was in French hands, the famed military engineer Vauban visited the city and drew up plans for its fortification.
Besançon had a reasonably democratic form of government, unlike most free imperial cities, which gradually became oligarchies.
[12] The protector, first the dukes of Burgundy and then the Austrian and Spanish Habsburgs had the right to appoint a president for the governors and the commander of the soldiers who guarded the ramparts.