Dr Gulhane said he wanted to stress the importance of learning how to do CPR and having defibrillators available nearby.
“There’s plenty of places where you can learn basic CPR and it’s free, like the British Heart Foundation, external or St John Ambulance, external,” he said.
“There’s no magic involved, it’s just a skill you can learn.
“But it’s also important to have a defibrillator because ultimately it was the defibrillator that saved this man’s life.”
He encouraged anyone who ever faced a similar situation to stay calm and work through simple steps to help bring the person back to life.
“If something happens, I’d encourage everyone to make sure it’s safe and start CPR, get someone to call an ambulance and get the defibrillator,” he said.
“It tells you what to do – the defibrillator will literally speak to you and tell you what to do.
“And don’t be scared, the 999 operator will also talk you through it and help you.”
A Scottish Ambulance Service spokesman confirmed it was called to the Scottish Parliament and a patient was taken to the Royal Infirmary of Edinburgh.
He added: “If someone has had a cardiac arrest, early CPR and use of a defibrillator are essential to increasing the chances of survival.”