Santa Margherita in Prigione is a genuine hermitage, a deconsecrated small 12th century church or chapel actually occupying one of the towers of the ancient city walls, west of the basilica of Santa Croce. This is in the rione Esquilino.
The dedication was to St Margaret of Antioch.
The main city walls as now known were a project initiated by the emperor Aurelian, and substantially complete by his death in 275. They are known as the Aurelian Walls. The chapel is just to the east of the ancient Porta Asinaria, later replaced by the present Porta di San Giovanni in 1574.
The origins of the church lie in a hermit colony established in the locality probably in the 12th century. The hermits, of both sexes, would have squatted in whatever derelict buildings were available including the rooms in the towers of the wall. This particular tower was converted into a chapel on the ground floor, and a single-room dwelling place in the room above accessible by ladder through the roof of the chapel.
A surviving documentary record describes St Dominic as visiting the city's immurati, literally meaning "those in the wall", in the early 13th century. These would have been these hermits. One particular female hermit called Bona is mentioned living juxta turris Portam Lateranensem, which was probably this hermitage.
Very early on the chapel was dedicated to St Margaret of Antioch, a martyr perhaps of the early 4th century associated with Antioch in Pisidia (now near Yalvaç in central Turkey). She is extremely obscure historically, but became popular in the Middle Ages because of her fantastic fairy-tale legend. She was a special protector of women giving birth.
In the 14th century, the interior was richly decorated with frescoes of the school of Pietro Cavallini.
Various papal bulls offered indulgences to pilgrims who visited the hermitage, especially on the feast-day of the saint which is 20 July. The site is near a former footpath from St John Lateran to St Cross, used by most pilgrims visiting the Seven Basilicas (the present road, Viale Carlo Felice, is modern).
From the 17th century the chapel was known as the “Prison of St Margaret”, which was the result of transferring the martyrdom of the saint to Rome. This historical falsehood may have come about because of her legend, which describes her as taming a dragon. This was probably conflated with the strange legend of the dragon in the Forum in the foundation legend of Santa Maria Liberatrice al Foro Romano.
This was still a working hermitage in 1648, since a report of the hermit becoming violently insane survives from that year.
The chapel remained open until 1878, when it was ordered closed because the tower was shedding masonry. It was reopened after two years after protests, and was restored in 1914.
Remedial work was done on the tower for several years from 1932 in order to control a lean which threatened to cause a collapse, and this seems to have occasioned the deconsecration of the chapel. The remains of the frescoes were discovered then, but were not preserved in situ but were removed to the museum in the convent at Santa Croce.
There was another restoration in 1978, and it was hoped eventually to conserve the structure to the extent that the frescoes might be returned. This had not happened by 2016.
The tower is best viewed from the Viale Castrense, outside the wall. It is the fourth, counting east from the Porta San Giovanni, and is marked by two arched apertures at the top, either side of the west angle. These may be the remains of a bell-chamber.
It is impossible to visit the other side without going through the gate and into the gardens on the inside of the wall. There one can see three round-arched windows in stone over the entrance.
The vaulted ceiling was frescoed to resemble a starry sky.
The walls had a fresco of Our Lady being venerated by angels, also depictions of St Catherine of Alexandria, St Margaret, SS Peter and Paul and St Benedict. There was also an unknown bishop depicted (perhaps St Blaise).