A Massachusetts retired detective has been charged with murdering his wife by prosecutors who say the man was having an affair and didn't want to share his pension when he fatally shot her--and then staged her death as a suicide.

Amy Fanion, 51, died of a gunshot wound to the head in May 2018. Her husband, Brian Fanion, 55, who served with the Westfield Police Department for 33 years, was indicted on a murder charge Thursday, prosecutors said.

Hampden County prosecutor Mary Sandstrom told a judge that Fanion was cheating on his wife at the time of her death. She said the affair began two months earlier and that Fanion didn’t want to get divorced because it would affect his pension, Fox 6 Springfield reported.

PENNSYLVANIA MAN, 76, CHARGED WITH KILLING WIFE WHO VANISHED IN 1981

Mugshot for ex-detective Brian Fanion, 55. (Hampden County District Attorney's Office)

“There was only one way to enjoy his retirement, to go on with his life and his new love affair and that was to murder Amy Fanion,” Sandstrom said, according to the station.

The prosecution says Fanion was planning to retire at the time of his wife’s death.

He called 911 to report that his wife died of a self-inflicted gunshot wound with his service weapon after he arrived home from work on his lunch hour, the Hampden County District Attorney’s Office reported.

Sandstrom said Fanion’s wife couldn’t have killed herself based on the forensic evidence, Fox 6 reported.

She also alleged that Fanion conducted incriminating internet searches hours before his wife’s death.

CANADIAN MAN WHO KILLED WIFE, THEN DAUGHTERS AFTER TAKING THEM TO CHURCH, SENTENCED TO LIFE

But defense attorney Jeffrey Brown read a letter in court from Amy Fanion’s family, saying they don’t believe he killed her, the station reported.

"We assert that Amy took her own life on May 8, 2018, and thus we are certain that her husband, Brian, did not take her life," Brown said.

He also denied his client was having an affair.

CLICK HERE TO GET THE FOX NEWS APP

Fanion was ordered held without bail after pleading not guilty.