"I am very happy. He is in reasonable shape, he is happy," Mr Rajoy said.
Mr Marginedas was abducted near the town of Hama and moved to different locations in areas controlled by the opposition to president Bashar-al-Assad.
Mr Marginedas is in Turkey with Spanish officials.
Meanwhile, an al Qaeda splinter group in Syria has denied it was behind the killing of a prominent al Qaeda figure last Sunday and appeared to reject an ultimatum from rival fighters to accept mediation or face all-out assault.
The Islamic State in Iraq and the Levant (ISIL) was responding to the killing of Abu Khaled al-Soury.
Two days after his killing, the head of al Qaeda's Syria branch, the Nusra Front, warned ISIL militants to accept the arbitration of Muslim scholars within five days to end their infighting or face a war which would wipe them out.
That deadline has expired.
Furthermore, activists said on Friday that ISIL fighters have withdrawn from the town of Azaz, near the Turkish border, five months after they took it from opposition fighters.
The Syrian Observatory for Human Rights said ISIL had been suffering heavy losses in Azaz and had pulled back to parts of eastern Aleppo province where it remains powerful.