Doctors declared Goncalves, 54, dead in Salvador, Brazil after "respiratory and multiple organ failure," the Daily Mail reported this week. His family was notified and made arrangements for the funeral later that day.
Goncalves' brother, Walterio, was let into the morgue to dress the body when he noticed something weird.
"As I got closer I could see it wriggling. Then I saw it raising and falling as if he was breathing," he told the Mirror. "I went crazy and shouted for the medical team, the nurse, so they could see what was happening. They checked him and confirmed that he was still alive."
The staff had to rush to free him; his body had been tied up and his nose and ears were filled with cotton wool, according to the BBC.
The Menandro de Farias Hospital, whose doctors declared Goncalves dead, has launched an investigation.
His niece, Patricia Cintra, told local newspaper Correio 24 Horas that the family was not only mortified -- they'd paid for everything.
"We had even bought a coffin and paid a deposit for the funeral," she said.
Still, she said her prayers had been answered when she found out her uncle was alive. He was diagnosed with terminal cancer three months before the heart attacks.
Goncalves can't speak, but he wrote a letter claiming that he was brought back from death by a Brazilian saint.
"I, Valdelucio, saw death at my feet, but my faith was so great that I was cured," he wrote, according to the Daily Mail. "Before Irma Dulce I said, do a miracle in me, and she heard my prayer. I saw my mother telling me, son, hold onto her and you will be saved."