See study by C. S. Manegold (2000).
Citadels are most often used to protect a garrison or political power from the inhabitants of the town it is defending. They were designed to ensure loyalty from the town which they defended.
For example Barcelona had a great citadel built in 1714 to intimidate the Catalans against repeating their mid 17th and early 18th century rebellions against the Spanish central government. In the 19th century, as soon as the political climate had liberalised enough to permit it, the people of Barcelona had the citadel torn down, and replaced it with the city's main central park, the Parc de la Ciutadella. A similar example is the Citadella in Budapest, Hungary. The Citadelle of Quebec still survives, as the largest citadel still in official military operation in North America, after more than two hundred years of existence.
In ancient Greece, the citadel, placed on a commanding eminence, was important in the life of the people, serving as a refuge and stronghold in peril and containing military and food supplies, the shrine of the god and a royal palace. In the Middle Ages the citadel was the last defense of a besieged army, often held after the town had been conquered, and affording retreat to the people living in the areas around the town.
In a fortification with bastions, the citadel is the strongest part of the system, sometimes well inside the outer walls and bastions, but often forming part of the outer wall for the sake of economy. It is positioned to be the last line of defense should the enemy breach the other components of the fortification system.
A citadel is also a term of the third part of a mediaeval castle, with higher walls than the rest of a town. It was to be the last line of defense before the keep itself.