A nurse found strangled to death in her bath was in a relationship with a man 25 years younger than her, the High Court in Belfast has heard.
Pauline Haveron, 53, began seeing her son's friend after he briefly went out with her daughter, a judge was told.
Lawyers for ex-husband Joseph Haveron, who is charged with murder, claimed the "open relationship" coincided with the deterioration of their marriage.
Mr Haveron denies killing his ex-wife. He was granted bail.
During a hearing on Thursday, his lawyer said his wife and her younger lover would be holding hands and kissing in their home.
"It was obviously very hurtful and difficult for him," he said.
Mrs Haveron's body was found at her home in Huntingdale, Ballyclare, last month.
The court heard she had been put in a bath of water, apparently to make it look as if she drowned.
Mr Haveron, a former RUC officer with an address at Farm Lodge Grove, Greenisland, was granted bail but ordered to have no contact with his wife's boyfriend Andrew Jones following comments he allegedly made to a friend who spoke to him about his ex-wife seeing a younger man.
According to the prosecution, Mr Haveron had said: "To tell you the truth I could kill the pair of them."
Troubled and distressed
A prosecution lawyer said that on the morning the murder was discovered he allegedly told a church pastor that he had "done things I can't be forgiven for".
"All of the witnesses who have been spoken to in relation to the applicant's demeanour in the church service on the day the body was found described him as being unusually quite troubled and distressed," she said.
Mr Haveron was said to have taken an overdose after learning of his former wife's murder and then stated: "Shoot me and get it over with."
He was arrested and questioned for four days before being released at first without charge.
Following his second detention it was alleged he told police: "I should have just driven off a cliff."
CCTV footage has been obtained of a car said to resemble Mr Haveron's which was travelling to and from the Doagh area on the morning of the killing, the court heard.
The prosecution lawyer said there were only about 50 matching Vauxhall vehicles in Northern Ireland, adding that efforts were being made to eliminate all others.
A defence barrister told the court how Mr Jones had been described as a friend of the victim.
The barrister said Mr Jones was a friend of one of Mrs Haveron's sons who then went out with her daughter for about a week.
"Then he formed a relationship with his (Mr Haveron's) wife who was 25 years older than Andrew Jones, and their marriage deteriorated," he said.
During his submissions the defence barrister said Mr Haveron had served for nearly 30 years in the RUC before leaving in 2003.
He had been a trained pursuit driver and witnesses "horrific" incidents, including a teenager blowing himself up in Belfast, during a career which led to him suffering post-traumatic stress symptoms.
The defence barrister said Mrs Haveron had been violent to Mr Haveron during their marriage.
"On one occasion he slept in the living room with the settee against the door to stop her coming in," he told the court.
Mr Haveron's lawyer disputed the quality of CCTV evidence, and insisted fingerprints found on the bath were not his client's.
The court also heard how Mr Jones normally stayed the night at the victim's home.
"On the night of Mrs Haveron's death he appears to have gone away that night and come back in the morning. That seems to be the Crown case," the defence lawyer said.
Ruling on the bail application, Mr Justice McLaughlin remarked how a divorce settlement was reached just three days before the murder.
"The circumstances in which the couple separated and maintained their separation and which led ultimately to their divorce were circumstances liable to cause extreme resentment," the judge said.
Mr Justice McLaughlin added: "One of the particular concerns is the safety of Mr Jones. It would appear, subject to further inquiries and further evidence, that the defendant has considerable resentment towards Mr Jones which may or may not be explained in whole or in part by the background to the matrimonial break-up which occurred in his own marriage."
However, the judge ruled that Mr Haveron should be released on bail on condition that he puts up a personal surety of £20,000, with a friend providing a further £5,000 guarantee.
The accused was granted bail but ordered to live with his father in Carrickfergus, curfewed, told to report daily to police, and banned from any contact with Mr Jones.