Madrid - Spanish morgue workers were given a major fright when a prisoner who had been declared dead after an apparent suicide attempt woke up just as they prepared to perform an autopsy, authorities said Wednesday.

In jail near Oviedo in northern Spain, the man, whom Spain's prison authority refused to identify, was found unconscious around 08:00 on Sunday and three doctors "found he presented no signs of life", a spokesperson told AFP.

According to Spanish media, the man is called Gonzalo Montoya, he is 29 and is in prison for stealing scrap metal.

He was taken to Oviedo's forensic medicine institute and woke up just as doctors were about to perform his autopsy, said his father Jose Carlos Montoya.

"He realised they were taking him out of the cover to put him on the table and do an autopsy," he told reporters, adding his son had been unconscious after swallowing pills in an attempted suicide.

Montoya said doctors had already put marks on Gonzalo's body for the autopsy.

Spain's prison authority and the government of the Asturias region where Oviedo is located have opened a probe into the case.