One of Hugh Montgomery's first patients, when he started working as an intensive-care doctor in 1989, was a 94-year-old woman who had suffered a heart attack while ballroom dancing. "She was a terrific, feisty old dear and we got on really well," recalls Montgomery. "But she ended up getting complications and falling unconscious. It was just a matter of time before she died.

"Every morning when I came into work, I would ask the nurses if she'd died, and they would say no. Then the thought crossed my mind that maybe she was hanging on for me.

"So I drew the curtains and said to her: 'I don't know if you can hear me, but if you're hanging on for me, you don't have to.' She stopped breathing right then. Maybe it was a coincidence, but I don't think so."

Montgomery relates the story because he is convinced that there is such a thing as the will to live and, by extension, a will to die. "I've seen this kind of thing happen so much in my work over the years that I don't believe it is a coincidence."

He tells the story of a church organist he treated. "She had a condition which meant she had to be on a drip, but she kept pulling it out. She told me: 'I don't want a drip any more.' I said: 'Your chances of surviving are very low if you don't keep it.' But she told me that Jesus was waiting on the other side and was calling her. She was with her husband and so I said: 'If you're both comfortable with that, do that. I can give you pain relief.' As I got up to go she said: 'Aren't you going to kiss me goodbye?' and so I gave her a kiss and left. Moments later she was dead.

"What I have found again and again is that dying patients hold on for a loved one to arrive - say for a son to get the visa to fly to London and see mother in hospital for one last time. My father, who was unconscious in hospital for the last couple of days of his life, died at the rare moment when we - my mother, sisters and me - were in the room at the same time."

Montgomery - a scuba diver, skydiver, high-altitude mountaineer, intensive care doctor, genetics researcher and director of the Institute for Human Health and Performance at University College London - is to give this year's Royal Institution Christmas science lectures about extraordinary cases of survival. What is it about certain people, he asks, that enables them to survive starvation, extreme cold, extreme heat or lack of oxygen? He suggests that genes, environment and luck all play a part. All five lectures feature guests who recount their own feats of survival - such as Jamie Andrew, who lost both hands and feet when caught in a five-day storm in the French Alps in 1999, during which a fellow mountaineer died.

But what Montgomery was not able to tackle in the lectures is the question of the will to live in medical situations. "I hope at some point to do a book about it because it is important to realise that psychology affects survival. It's a fascinating question."

But it is also a controversial one. Is Montgomery suggesting that some people who succumb to fatal illnesses may just lack the will to survive? "No. It's important not to generalise - otherwise you end up insulting the dead and upsetting the bereaved." Nor is his suggestion faith-based: "When I talk about the will to live, which very few people do, I'm not talking about intervention with prayer. I'm talking about behavioural psychology. What I am saying is that one's mental attitude or emotional state can cause fatal illnesses or help one survive. There's a lot of data to suggest this is the case."

He cites the so-called Whitehall study by Sir Michael Marmot, professor of epidemiology and public health at University College London, which concluded that life expectancy and susceptibility to fatal disease can be influenced by social status. Marmot surveyed civil servants and found that, of those who suffer coronary heart disease, what was important wasn't just diet or whether a person smoked, but sense of status. "Middle management were in the worst position in terms of stress, because they had low status," says Montgomery. "The higher-ranking people were OK because they would say: 'Make it so,' and walk away. They didn't have the stress of putting something into practice. The middle managers did and they were stressed as a result.

"The point is one's emotional condition - stress - can cause coronary disease. The St John Ambulance see this a lot - people who have heart attacks at football matches."

All Montgomery's examples are to do with coronary disease. Does he not think that his theory applies to, say, cancer patients too? "Well, I think they can certainly exhibit in some circumstances the will to live. I just don't work with them as much as with the kind of case I've mentioned."

In his lectures, Montgomery focuses on cases of survivors in more dramatic life-or-death situations - fitting, perhaps, for a doctor who is himself familiar with extreme activities. Montgomery once jumped out of a plane at 14,000 feet with no clothes on, he has twice run a 100km ultra-marathon, and reportedly holds the world record for underwater piano playing (110 hours). He also once stayed awake for eight days in a row at work.

Extreme situations clearly intrigue Montgomery. He is fascinated by the fact that survivors often mentally rehearse how they would behave in life-or-death situations, and connects such behaviour to his notion of the will to live. The yachtsman Tony Bullimore, after his yacht capsized in 1997, managed to survive for five days in the upside-down boat, having lost his food supplies. "He had, as it were, a survival kit and knew how to use it." After his ordeal, Bullimore said he had survived on "a little chocolate, water and sheer determination".

A high level of mental activity can make the difference between surviving and perishing too, he argues. Montgomery mentions Edward Brudno, an American pilot who spent seven and a half years as a prisoner of war in Vietnam. During that time, he learned French and mentally designed a dream house down to the last floor joist. He also composed and memorised a diary of his imprisonment in verse.

When he was released in 1973, Brudno asked for a tape recorder so he could record the poem. "It took him 45 minutes!" says Montgomery. "He had really kept his mind occupied, which was probably important to his survival."

Montgomery also talks about Joe Simpson, the mountaineer whose book Touching the Void (later a film) detailed his 3,000ft solo descent from the Siula Grande in the Peruvian Andes with a broken leg in 1985. "A lot of survivors in these situations survive because they break what they have to do down into little tasks. If I was told I had to climb the north face of the Eiger to survive, I might just think, 'Forget it. I can't do it. I'll just die.' Or I might break it down into little tasks, each one of which I would accomplish before moving to the next."

Montgomery concedes that more work is needed on the notion of the will to live. "But when you come - as I often do - across two patients who seem to be in a similar condition and have the same strengths and weaknesses, but one dies and one lives, I'm convinced there is a will to live and that it's important in deciding who survives"

· The Christmas Lectures will be broadcast on Channel Five at 7.15pm from December 24-28.