Ashley Sibery, 39, persuaded Sital Sibery to take the class A drug minutes after she confronted him about his drug habit in their home.
It happened on 2 April 2012 at their London Street property.
Sibery pleaded guilty to a charge of culpable and reckless conduct at Edinburgh Sheriff Court.
The court heard that when Mrs Sibery decided to confront her husband because of his erratic behaviour, the GP admitted he had been using the narcotic for two months.
She told him if he did not quit his addiction, she would end his marriage to him.
But despite the ultimatum, Sibery managed to persuade his wife into taking what was supposed to be his final fix.
The court heard how Sibery wanted his wife to experience the feeling he got when he took the heroin.
However, Mrs Sibery collapsed and started having difficulties breathing.
The court also heard that Sibery, who was on bail for the offence, was now in the care of a consultant psychiatrist who was helping him to tackle his problems, and that he and his wife were still together.
Sheriff Jarvie told Sibery that she would pass sentence on him at a hearing next month.

Shaun Ingram from Saltash booked his Ford Focus ST in for a major service at Halfords Autocentre in Plymouth in March.
On its return he discovered the dashboard camera recorded footage of his car being driven 57 mph in a 30 mph zone.
Halfords said the mechanic was a temporary employee who had been let go.
After the complaint the company has apologised and offered to refund the Â£255 for the MOT and service.
Mr Ingram said the camera was in plain sight on the windscreen and was not left on to "catch anybody out" during the service.
The camera recorded almost seven hours of footage including the mechanic swearing and talking about test-driving the car.
Mr Ingram said: "When I saw the footage I was left open-mouthed. The mechanic was abusing my car and my trust.
"As a nationwide company I thought I had nothing to worry about. I feel very let down."
The regional manager for Halfords Autocentres, Daren Stone, told Mr Ingram that the mechanic's behaviour was unacceptable.
He said: "He drove your car in what I can only describe as an appalling manner.
"I do not and will never condone that level of pure neglect which is why the mechanic in question has been removed from working within the Halfords Autocentre Group."
Mr Ingram said: "From now on I will always wait by the car whilst it is being serviced."
A spokesperson for Halfords head office said: "We are looking into the full details of the incident and will deal with this issue internally as a matter of urgency to ensure this type of incident does not occur again in the future."
A drug-addicted doctor watched his wife lose consciousness and struggle for breath moments after injecting her with heroin in Edinburgh, a court has heard.
[NEXT_CONCEPT]
A Halfords customer's dashboard camera caught a mechanic speeding in his car while it was booked in for an MOT.