Over the years, it has been exposed to several invasions.
San Marino has never been invaded and has always maintained its independence. Cesare Borgia attempted unsuccessfully to seize it in the 1500s and 1700s, and it even resisted joining the Papal State. Fortunately, when the Napoleonic army came in the 18th century, San Marino was a political entity with a republican government. They retained its autonomy while also making economic concessions to it. The three distinctive towers of the old town, which are also featured on the flag, represent the tenacity of the Republic.