Around the early 16th century , following the construction of the Ribeira Palace beside the Tagus river , the Palace of Alcáçova began to lose its importance . An earthquake occurring in 1531 further damaged the old castle , contributing further to its decay and neglect . In 1569 , King Sebastian ordered the rebuilding of the royal apartments in the castle , intending to use it as his official residence . As part of the rebuilding , in 1577 Filippo Terzi demolished one of the towers near the principal facade of the Church of Loreto . However , many of the works were never completed after the young king 's apparent death during the Battle of Alcácer Quibir . The following Portuguese dynastic crisis opened the way for sixty years of Spanish rule and the castle was converted into military barracks and a prison . On 30 December 1642 , Teodósio de Frias the Younger was appointed master builder to continue the works begun by his father , Luís de Frias , and his grandfather , Teodósio de Frias . This was part of a greater plan by the Spanish forces to recommission the fortification . However , after Portugal regained its independence following the Portuguese Restoration War , the works were taken over by the Portuguese government . On 6 November 1648 , Nicolau de Langres was called upon to take over the design , execution and construction of a new fortification that would surround the Castle of São Jorge and the city walls of Lisbon . In 1650 the military architect Mateus do Couto was named master builder of the project and reconstruction took on a new formality : although the military engineer João Gillot built new walls in 1652 , construction again followed Couto 's plans between 1657 and 1733 . In 1673 , the Soldiers ' Hospital , dedicated to '' São João de Deus '' ( St John of God ) , was installed on the grounds beside the Rua do Recolhimento . At the end of the 17th century the '' Recolhimento do Castelo '' ( " Castle Shelter " ) was constructed along the southeast angle of the courtyard , and in 1733 , new projects were initiated by master Custódio Vieira
earthquake
1531 Lisbon earthquake
São Jorge Castle