Francoist troops occupied Barcelona on January 26, 1939 with the 105th Division of the Moroccan Army Corps in the vanguard and soon after they would enter the Castle. In this way, the Castle became part of the national side and temporarily became a place of concentration, with thousands of prisoner soldiers, who would later be transferred to the Horta concentration camp.
The case that achieved, however, more political and symbolic significance was that of the imprisonment and execution of President Lluís Companys. On August 13, 1940, he was arrested in La Baule, in France occupied by the German army, by order of the Spanish authorities, and imprisoned in the Parisian prison of La Santé, from where he was handed over to the 'Franco Spain. After a few days in the General Directorate of Security in Madrid, he was transferred to Barcelona and entered Montjuïc, where he remained locked up and isolated from the other prisoners, in the military chaplain's cells located in the Castle's courtyard . On October 3, a judicial process was initiated that was concluded in just ten days, so that on October 14, 1940, a very summary war council took place that lasted less than an hour and ended with death sentence. The facts that were imputed to him were opposing the Uprising and tolerating crimes in the rear, in addition to military rebellion. On October 15, at six in the morning, he was shot in the moat of Santa Eulàlia. The Castle was deeply marked by this crime.
This character of a military prison was maintained until 1960.