A Moray doctor alerted the police after a patient said he was going to kill his ex.
Alan Whyte intimidated his former lover with abusive texts and threatened to set fire to her parent’s car.
But the 28-year-old was only stopped when he told hospital staff he was “not afraid to kill her”.
Yesterday Whyte was jailed at Elgin Sheriff Court after he admitted bombarding Ms Taylor with offensive messages which threatened her and her family.
He also admitted making menacing comments to staff at the Pluscarden Clinic in Elgin.
Fiscal depute Kevin Corrins said the accused and Lisa Taylor had been in a relationship for six years, but split up around three years ago.
He said that a string of abusive messages had been sent shortly before 3am on January 5 this year.
One read: “You know I will kill you, Lisa. I am not scared to.”
While another said: “Tell your mum and dad to watch their car doesn’t catch fire after I am done with it. It will be any time, so better watch the kids don’t go in it.”
A third message from Whyte told her family to “go and have a wash because I can smell them from here.”
The court heard the following day, he went to the clinic for an appointment with doctors.
Mr Corrins added: “During the meeting, he made a very specific threat to stab Lisa Taylor and made reference that he was going to murder her.
“When asked to explain what he meant, he said he would stab her with a knife.”
Police were immediately alerted about the comments and officers were sent to her home to check on her safety.
After opening the door, Miss Taylor showed police the menacing messages which she had received the night before.
During an interview with police, the Elgin resident told officers that “voices” in his head had told him to make the threats.
But Mr Corrins said that when Whyte went to the medical practice doctors did not find him to be mentally ill.
Defence agent Stephen Carty said his client did have a history of mental health problems and that alcohol also had a “significant effect”.
He said Whyte had not seen his children for two years and was eager to make arrangements to see them again.
Mr Carty said: “He understands why the complainer was not content to allow contact. Mr Whyte accepts he must use formal channels if he wants to see the children. He apologises unreservedly.”
Sheriff Chris Dickson told him a prison sentence was the only appropriate sentence.
Whyte, of Kingsmills in Elgin, was jailed for 200 days and banned from contacting Miss Taylor for two years.