Ainsley Francis, 57, of Maidstone, Kent, tracked the movements of former wife Barbara Stokoe through a voice activated recording device he bought on eBay and placed in her bedroom.
Over a three-year period he allegedly sent threatening messages to Ms Stokoe and entered her home at will when she was on holiday.
Police found 187 audio recordings on Francis’s mobile phone of Ms Stokoe making phone calls, using the bathroom and even having sex.
A judge at Maidstone Crown Court sentenced Francis to 45 months in prison on Friday, saying his “malicious” actions were “breathtaking”.
Francis, who has served as a police officer for 29 years, admitted an offence of stalking, involving fear of violence or serious alarm or distress at an earlier hearing.
Prosecutor Richard Job on Friday told the court that the offences took place between May 1 2014 and March 16 2017.
The couple first met in 1988, later separating in 2012 before enduring protracted and “acrimonious” divorce proceedings.
Each went to live in separate properties, one of four owned by the pair, but Francis would continue to visit his wife and their son William.
The divorced couple’s relationship soured after Ms Stokoe began a new relationship with a man named Anthony Lock.
Over a long period Francis began bombarding Ms Stokoe with emails and phone calls, including asking her for “compromising” photos of herself.
Mr Job said: “It was clear from the messages that Mr Francis was sending to Ms Stokoe at this time that he was familiar with her movements”.
Francis would repeatedly drive past Ms Stokoe’s home, could describe Mr Lock’s bedding and even threatened him with violence.
Once when Ms Stokoe and her partner went on holiday to India they returned to find someone had been in her house and letters had gone missing.
Francis also falsely accused Ms Stokoe of taking a second lover of a man named only as R, which could have been a reference to her plumber.
Mr Job added that the most “sinister” aspect of his offending was placing a secret recording device by her bed.
“An item that might be described in espionage movies or novels as a bug,” Mr Job said.
Ms Stokoe, who attended court on Friday, confronted her ex-husband who admitted he regularly entered her house in her absence.
Following his arrest, Francis said he had placed the device because he was “seeking to prevent the commission of crime”.
Mitigating, Mr Edmund Gritt said Francis had been commended for his “bravery” as a police officer by colleagues.
His career had been affected by a heart condition and a spinal injury sustained in a serious car crash in the 1990s.
“He apologises to his former wife and Mr Lock for his disgraceful treatment of them,” Mr Gritt said.
Sentencing, Judge David Griffith-Jones QC, said Francis’s actions had been “devious, malicious and extraordinary to the point of being breathtaking”.
“You seek to advance a form of explanation for your behaviour over that extended period of time by saying you had lost perspective,” he said.
“That seems to me an understatement and frankly inappropriate sanitisation of what amounts to criminal behaviour.”
Mr Griffith-Jones said Francis had been driven by a “twisted determination” to control his ex-wife and should be “ashamed” of his actions.
He added: “Your actions completely change her life and she now questions whether she will ever recover, referring to her feelings of violation, helplessness and intimidation.
“I very much hope the culmination of these proceedings will draw a line in the sand for her.”
Francis, who has no previous convictions, was sentenced to 45 months in prison for the offence of stalking, involving fear of violence or serious alarm or distress.
He will also be subject to a restraining order preventing him from contacting Ms Stokoe.
The prosecution had previously requested that a separate charge of possessing a prohibited weapon for the discharge of noxious liquid be laid on file.