If there's one surefire way to make sure your funeral is remembered, it's turning up at it alive.

That, at least, was the experience of Gilberto Araújo, a 41-year-old car-washer from Brazil, whose unexpected arrival at his own wake reportedly sparked terror and then delight among his family and friends.

Araújo's family, from the town of Alagoinhas, about 70 miles from Salvador, had mistakenly identified a body in the local morgue as his and were mourning his death on Sunday night when the man they believed was in the coffin beside them showed up at the front door.

"A friend told me there was a coffin and that I was inside it," he said. "I said, 'Guys, I'm alive – pinch me,'" Araújo was quoted by the O Globo news website.

His appearance prompted some people to faint and others to flee in panic.

His mother, Maria Menezes, a shopkeeper, said: "It was a fright. I'm very happy because what mother has a son that they say is dead then turns up alive?"

The mixup is reported to have stemmed from the fact that another car-washer in the town, who closely resembled Araújo, was murdered at the weekend, and police called Araújo's brother, José Marcos, to tell him they believed his brother was the dead man.

The brother then went to the morgue and wrongly identified the body. "Police called my husband and told him that his brother had been killed and his body was at the morgue," Jose Marcos Araujo's wife, Ana Paula, told the UOL website.

Police Inspector Roberto Lima said the confusion was "understandable", as Araújo and Genivaldo Santos Gama, the man later named as the real murder victim, looked so alike. "The two men closely resembled each other and both worked as car-washers," he said.

Araújo said he had learned of the mistake from an acquaintance, who had come up to him in the street to tell him his family was setting off for his funeral. He had tried to tell them he was still alive by telephoning, he said, but his call was dismissed as a cruel prank. There seemed nothing for it but to turn up in person.

"He went to his mother's home to let everyone know he was very much alive," said Lima.