Martin Turkiewicz is accused of attempted murder after prosecutors said he tried to kill his wife with a hammer. (WHAM)

Buffalo, N.Y. (WHAM) - A man from Cheektowaga is accused of attempted murder after prosecutors said he tried to kill his wife with a hammer.

Martin Turkiewicz, 88, went to visit his wife Rita at a rehabilitation and healthcare facility in Buffalo on Saturday. According to our ABC affiliate WKBW, Martin attacked his 86-year-old wife with a hammer, hitting her once in the head. She survived the attack.

Defense attorneys said Rita has dementia and Martin has been caring for her for the last seven years. They added that the attack was a "crime of compassion" and that Martin wanted to end his wife's suffering.

Turkiewicz's daughter spoke to the court, saying her father is not a flight risk and he takes care of an adult son who is blind. She said Martin is a loving family man and not a flight risk.

Bail was granted by the judge at $10,000 cash or $50,000 bond.

An order of protection for Rita has been issued, stating Martin cannot contact her in any way.

The couple's daughter agreed to stay with Martin as part of the release agreement. Bail will be rescinded in the event that she leaves him unattended.