The structures that remain today of what was, until 1834, the university prison (when, as a result of the liberal revolution, the jurisdiction of the University Registrar over the teachers, students and families was extinguished), correspond to three distinct phases in the use of the place: the first, highly connected to the original structures of the Royal Palace, and the others mostly related to the University occupation.
It was necessary to create foundations capable to hold the construction of the House of the Library, known as the Baroque Library, built from 1717 onwards.
In order to overcome the difference in height of the upper courtyard, the prison would then support the noble rooms and it would be used as storeroom. It would also comprise the remains of the old medieval prison that existed in the Royal Palace, built at the end of the 14th century outside the Muslim walls.
It is the only existent medieval prison in Portugal. Of its original constitution the so-called "secrets", which consist of a spiral staircase and a straight staircase with a gothic parapet, have reached the present.