Ashley Sibery, 39, of Edinburgh, persuaded Sital Sibery to take the Class A drug after she confronted him about his recent erratic behaviour.
He admitted to her he had been using the lethal narcotic for two months, Edinburgh Sheriff Court heard yesterday.
Mrs Sibery told him that if he did not quit his addiction, she would end their marriage.
Despite the ultimatum, Sibery managed to persuade her to share in what was supposed to be his final fix.
The court heard how Sibery wanted his wife to experience the feeling that he got when he consumed the brown powder.
However, she collapsed and started having difficulties breathing. Paramedics who attended their home recognised the former accident and emergency doctor and managed to save Mrs Sibery's life.
Sibery was then arrested and confessed his involvement in the potentially lethal incident to detectives.
Sibery, of London Street, Edinburgh, yesterday pled guilty to a charge of culpable and reckless conduct before Sheriff Elizabeth Jarvie QC.
Solicitors and people in the public benches sat in open- mouthed silence as depute procurator-fiscal Karen Rollo narrated the circumstances surrounding the case.
Ms Rollo told the court the incident took place on April 2 at their London Street home.
The court heard that prior to this, Sibery worked in the city as a general practitioner. He qualified as a medic in 2002 and had once worked in accident and emergency.
Ms Rollo told Sheriff Jarvie that the pair had an argument about how Sibery had been behaving. She added: "He had admitted to her that he had spent the last two months injecting heroin into himself.
"She issued him with an ultimatum. She told him he had to stop taking the drug or their marriage would be over.
"Bizarrely, he asked her if she wanted to try some. He told her that he had a small quantity of heroin remaining in the house and that he would give her it.
"He wanted her to experience the drug, to see what it was like. The heroin was then prepared and it was injected into her.
"Within a few minutes, she collapsed and lost consciousness. She started to have breathing difficulties.
"An ambulance was then called to the house. The paramedics who attended the scene recognised him as being a doctor. They managed to keep her breathing and also stabilised her condition.
"She was then taken to hospital and received treatment."
Ms Rollo then told the court that police arrested Sibery.
The doctor confessed to them that he had given his wife heroin and that he had an addiction problem.
Ms Rollo added: "The accused indicated that he had a heroin habit. He confessed to them that he had given his wife heroin.
"He told them that he wanted to relax her and deal with stress. He told the officers how she slipped into unconsciousness."
The court heard that Sibery – who was on bail for the offence – was now in the care of a psychiatrist who was helping him to tackle his problems.
The court also heard that he and his wife were still together.
Sibery will be sentenced after reports are obtained next month.
Alan Boyter, director of human resources and organisational development at NHS Lothian, said: "Since this matter came to light, this individual has not carried out any duties for NHS Lothian.
"It would be inappropriate to comment further."
Contextual targeting label: