The man, referred to as Mr C, was admitted to accident & emergency (A&E) at Aberdeen Royal Infirmary with stomach pains in November 2012, almost two weeks after being discharged following heart surgery.
Staff decided at 9.20am that he should be transferred to the acute medical assessment unit (AMAU) but he was not moved there until around 8.20pm.
For much of the time in A&E he was lying on a hospital trolley, the Scottish Public Services Ombudsman (SPSO) said.
After he was transferred, he became unwell and died the next day, with the cause of his death recorded as an ischaemic bowel (inadequate blood flow to the intestines), related to a heart condition.
His wife Mrs C, who also has health problems, was at home 60 miles away and when called to come to the hospital urgently was not able to get there before her husband died.
She complained to the SPSO, saying that the care and treatment provided to her husband were "unreasonable".
Mrs C also complained that the health board asked her to sign her husband's death certificate before she had a chance to see him, and that when she did see him staff had not laid him out properly, which she found distressing.
She said that when she saw Mr C in hospital after his death, he looked as if he had died "in extreme pain" and that she has not been able to remove the image from her mind.
Grampian NHS Board said that Mr C was monitored and assessed frequently in A&E and was provided with a bed there after about six hours.
It apologised for the time he spent in A&E and the delay in a doctor seeing him after he was transferred, and for the distress caused when Mrs C saw him shortly after he died.
The Ombudsman upheld all of Mrs C's complaints, saying that whether or not he was eventually provided with a bed in A&E, Mr C was on a trolley for too long and received no further treatment there.
He also said that the board had not let Mrs C know about her husband's decline as quickly as they should have done, and that she had been treated with a "fundamental lack of sensitivity", both with regard to when she was asked to sign her husband's death certificate and to seeing him after he had died.
The Ombudsman made a number of recommendations, including asking the board to provide him with their plan showing what they have done to prevent Mr C's experience in A & E happening again, and emphasising to A & E staff the importance of keeping accurate clinical records.
He also asked the board to ensure staff are aware of their responsibilities to preserve dignity in death and be sensitive to the needs and feelings of family members.
An NHS Grampian spokesman said: "We accept all aspects of the Ombudsman's report.
"On this occasion we fell well short of the standards of care and compassion we aspire to. We regret the care offered to Mr C was inadequate and that our actions caused additional distress for him, for Mrs C and for their family.
"Mr (Richard) Carey, chief executive, wrote to Mrs C on March 13 last year and, with senior clinicians from the emergency department, met her on March 25 to discuss the investigation carried out by NHS Grampian.
"However, as requested by the Ombudsman, we will be writing again to Mrs C to offer an unreserved apology for the distress caused.
"All of the recommendations will be acted in on as part of an action plan which will be shared with the Ombudsman. We are absolutely committed to learning lessons from this tragic incident."