At the beginning of 1486, the area of the Patio de San Martín was designated as the headquarters of the Tribunal of the Holy Office of the Inquisition and rooms adjacent to the patio were set up to house the officials of this organization. This is probably the origin of the Torre del Trovador being used as a prison. In some books the year 1485 appears.
This organization was housed in the Aljafería until in 1706 it moved to the Plaza del Carmen and, after several changes of headquarters, in 1759 to the Villahermosa palace, on Calle de Predicadores; It is not daring to assume that when such changes were made it was because the Aljafería building must have been in poor condition, which would increase with abandonment, remaining in partial ruin until the installation of the barracks. (Beltrán, A. (1970). La Aljafería. Zaragoza City Council. p. 111).
The new function (which would last until the early years of the century) triggered an event that would culminate in a reform project undertaken under the mandate of Philip II, which would henceforth become a military base. Numerous works were carried out in the Aljafería to turn it into a citadel. In 1591, in the events known as Alteraciones de Zaragoza, the persecuted secretary of King Philip II, Antonio Pérez "Antonio Pérez (royal secretary)") took advantage of the Privilege of Demonstration contemplated by the jurisdiction of Aragon in order to elude the imperial troops. However, the Court of the Inquisition had jurisdiction over all the jurisdictions of the kingdoms, and, for this reason, he was confined in the dungeons of the inquisitorial headquarters of the Aljafería, which caused an uprising of the people in the face of what they considered a violation of regional law, and they went to the assault of the Aljafería to rescue him. After the forceful action of the royal army, the revolt was put down, and Philip II decided to consolidate the Aljafería as a fortified citadel under his authority to prevent similar revolts.
The design of the work, which consisted of a "modern" military building, was entrusted to the Sienese military engineer, Tiburzio Spannocchi. He built a set of rooms attached to the south and east walls that hid the ultra-semicircular towers inside, although on the east façade it did not affect those flanking the entrance door and from these onwards. Surrounding the entire building, a crenellated wall was built that left a space for a walkway inside and ended at its four corners in four pentagonal bastions, the beginnings of which can be seen today. The entire complex was surrounded by a twenty-meter-wide moat, re-excavated in 1982 at the initiative of the architect Ángel Peropadre Muniesa"), which was spanned by two drawbridges on the east and south flanks. The appearance of this new plan is reflected in the plan of the Aljafería as we know it after the last restoration completed in 1998.
The Aljafería of Spannocchi remained without substantial changes until 1705, when due to the War of the Spanish Succession it was the accommodation of two companies of French troops, which led to an increase in the parapets of the lower wall of the moat carried out by the military engineer Dezveheforz.
But the decisive transformation as a barracks occurred in 1772 at the initiative of Charles III, in which all the façades were remodeled to the way the western façade is currently presented, and which converted the interior spaces into rooms for the soldiers and officers who stayed in the building. In the western third of the palace, a large parade ground was configured into which the rooms of the different companies flow, made with simplicity and functionality, following the rationalist spirit of the second half of the 18th century and the practical purpose for which the areas built at that time were used. The only thing left pending was the addition in 1862 of four neo-Gothic towers, of which those located in the northwest and southwest corner have survived to this day.
The military part consisted of a large moat, with escarpment and counterescarpment and a fortification of four curtains built with a barbette on the wall of the escarpment that advances forming a covered path and a promenade that runs along the entire perimeter. The moat was crossed in front of the main door by a brick bridge, later replaced by a wooden one with a portcullis. (Beltrán, A. (1970). La Aljafería. Zaragoza City Council. p. 114-115).
Philip V's reform put the castle in a position to house around 3,000 men, more as a barracks than as a fortress and, ultimately, it did little damage to the essential structures. (Beltrán, A. (1970). La Aljafería. Zaragoza City Council. p. 117).
It was precisely in the middle of the century when Mariano Nougués Secall raised the alarm about the deterioration of the Andalusian and Mudejar remains of the palace in his 1845 report entitled Description and history of the Aljafería castle, a rigorous study in which he urged the preservation of this valuable historical-artistic complex. Even Queen Isabel II contributed funds for the restoration, because in July 1845 she visited the Aljafería and we know that for this reason the rooms were whitewashed and some were cleaned, and a commission was created in 1848 to undertake it; But in 1862 the Aljafería passed from the property of the Royal Heritage into the hands of the Ministry of War, which aborted its restoration and aggravated the damage caused. The aim was to ensure that nothing remained standing of the old Arab palace, not even the mosque.
The castle then took on the barracks appearance that it had until recently, with four angular towers, a monotonous brick exterior with three floors over which the small tower, built or renovated at that time, stood out; The Artillery Park turned the royal halls into weapons depots and everything was masked and changed; The Troubadour tower was the master armorer's quarters and dungeons. Very little was left of so much desolation and in a very short time even the names of the rooms of <<the marbles>>, the <<Fireplace>>, the <<Paraments>>, the <<Jars>> were forgotten, since not even plans were made or notes were taken of what was destroyed. (Beltrán, A. (1970). La Aljafería. Zaragoza City Council. p. 119).
The deterioration continued until in 1947 when the architect Francisco Íñiguez Almech undertook, practically alone, the task of its comprehensive restoration, in which he was occupied until his death in 1982.
In the 1960s it was used as a military barracks, and the decoration was covered with plaster.
In 1984, the parliamentary commission created to search for a definitive headquarters for the Cortes of Aragon recommended locating the regional parliament in the Aljafería palace and the Zaragoza City Council (owner of the building) agreed to transfer part of the complex free of charge for this purpose for a period of 99 years.[8]
In this way, the restoration operations gained new momentum with the actions of Ángel Peropadre, Juan Antonio Souto (in archaeological work), and, starting in 1985, Luis Franco Lahoz and Mariano Pemán Gavín, who carried out the final restoration project of the Aljafería for the location of the headquarters of the Cortes of Aragon.
Once the works were completed, the Aljafería was inaugurated as a historical-artistic monument in 1998 by Prince Felipe de Borbón.
"Hospital, headquarters of the Inquisition, and now, the epicenter of Aragonese democracy, the process to rescue that dreamed Islamic palace began many years before the Cortes of Aragon was established and its reform was not completed until 1998. "A rescue process that began in the 50s and was initiated by the professor and architect Francisco Íñiguez, who is eliminating parts of the old barracks and recovering that lost and dreamed Islamic palace that was under the barracks", explained the architects of the final work, Mariano Pemán and Luis Franco.
The reform would cost more than 200 million pesetas, which would be equivalent, now, to 1,200,000 euros. The result is a building in which multiple styles coexist and that shares its parliamentary use with its tourist use.''