The Most Serene Republic of San Marino, a tiny enclave within Italy, was born during the Middle Ages as one of the many independent city-States.
Surrounded by the Pontifical States, San Marino maintained a de facto independence thanks to the ambiguity of the canon law, based on the principle of universal sovereignty rather than national one.
When Napoleon descended into Italy, he also respected San Marino’s independence as a tool to counterbalance what was left of the papal power. He even offered to add territory to the Republic, an offer which was politely rejected.
The fragile status quo was altered when the new nationalistic ideas took hold in the new unified Italy. San Marino became an Italian protectorate (a 1897 Treaty declared the existence of a “protective friendship” with Italy) and in the Twenties it was taken over by the local Fascist Party.
Today, in a drastically mutated international legal framework, there is no serious doubt on the actual sovereignty and independence of San Marino. As many micro-States, the Republic survives thanks to tourism and a eroding bank secrecy.