At the summit of the hill on which San Marino is built is La Rocca, more properly called the "Guaita" (or First Tower -- the first of the towers whose turrets feature on the republic's coat of arms). It's really a fortress rather than just a tower, and dates back to the 1000s (though you can tell from its fairly pristine look that it's been renovated and been given a lick of paint or 3 much more recently than that). Amazingly, the pentagonal structure was not built or constructed but sculpted direct from the stone of the hilltop for use as a look-out tower and part of the fortification.
Now you know the republic's somewhat turbulent history and their (understandable) paranoia about being a tiny country within an enormous and not always friendly neighbour, you'll know why the fortress was deemed necessary -- having said that, it didn't stay a fortress forever but, until as late as 1970 was a working prison. Indeed, a so-called "tower of penance" (built shortly after the impressive bell-tower) was built in medieval times as a punishment by misbehaving inhabitants.
Having climbed all the way up there from the city centre below, you'll be pleased to see a cafe with good icecreams in summer time and even better espresso in colder climates.
Once you've fortified yourself, you go in beneath a now-familiar republican escutcheon (three towers - "Liberta") which you'll have seen on the clocktower of the Palazzo Publico (and from my photos to this section). In particular, admire the splendid bell tower and climb up to enhance yet further the magnificent view across the valley as far as Mt Titano. Definitely worth the climb up to the hilltop, especially on a good clear day. Once you've had your fill of climbing and views, visit La Cesta o Fratta, one of the other towers of San Marino, where you'll find a medieval weapon museum.