David Gilroy, 49, admitted cheating on his partner Andrea, 42, when he spoke to police two days after Ms Pilley, 38, disappeared on her way to work in Edinburgh.
The High Court in Edinburgh yesterday heard how Gilroy made the admission during an 11-hour-long statement to Sergeant Paul Grainger at Corstorphine police station in Edinburgh just after midnight on May 6, 2010.
The police officer, 39, told prosecution lawyer Alex Prentice, QC, that Gilroy had claimed to his staff nurse wife that he was working when he was actually seeing Ms Pilley.
The court also heard Mrs Gilroy had discovered his relationship with Ms Pilley, and that this prompted him to move in for a time with the book-keeper.
However, the relationship ended and he returned to live with his family.
The revelation came on the ninth day of the trial of Gilroy, who denies murdering Ms Pilley at Thistle Street, Edinburgh, or at another location in Scotland on May 4, 2010.
The court heard how Gilroy, a former Royal Navy engineer, met Ms Pilley on a work night-out in Edinburgh in spring 2009.
He said he began having a relationship with her after getting to know her doing odd jobs around her flat in the capital's Saughton area.
During the relationship, he said the divorcee had told him she had been abused during a previous relationship and that she was previously married but had split up from her partner because she didn't "fancy" him.
Gilroy also told police Ms Pilley had told him she had a "termination" when she was younger but now wanted to have children.
He also claimed Ms Pilley had told him she met her "soul mate" during a trip to Morocco but had ended that relationship to return to Scotland.
She also allegedly told Gilroy she had been engaged to another man in Edinburgh, but that relationship had ended because the man had a "cocaine problem".
The court had earlier heard Gilroy had gone to police after spending part of his day in Lochgilphead, Argyll and was interviewed as a witness.
Sergeant Grainger, who had taken part in attempts to trace Ms Pilley after she went missing, said Gilroy appeared to be happy enough to talk to him. He added: "He was quite happy to come and assist us. There was nothing unusual or different about him."
In his statement, Gilroy admitted his wife thought he had "betrayed" her after she found out about the affair with Ms Pilley.
He said their relationship had then become strained.
One part of the statement, which the jury heard, read: "She always picked fault with me because I betrayed her."
Sergeant Grainger – who now works for Lothian and Borders Police's Serious and Organised Crime Unit – also said that he noticed Gilroy had a number of injuries during the interview.
He told Mr Prentice: "I noticed a scar on his forehead under his hairline. There may have been some sort of scratch to his neck under his chin."
Gilroy, of Silverknowes, Edinburgh, denies a total of five charges which allege he committed a series of criminal acts across Scotland between August 2009 and June 2010.
The trial continues.