Stephen Fry’s attempt to kill himself last year happened while he was filming a BBC2 documentary in Africa about the mistreatment of gay people, it has emerged.

The actor and TV presenter had been in Uganda, a country famous for its intolerance of homosexuality, when he tried to commit suicide with a cocktail of vodka and pills.

Mr Fry was saved after being been discovered in his hotel room, a day after the production had completed filming in the country, by its producer and director Fergus O’Brien.

Better spirits: Stephen Fry, pictured at the Ormeley Dinner in London last night, recently spoke out about his suicide attempt

The popular performer was then taken back to England and the making of the two-part documentary, called Out There, was put on hold until he had recovered from the incident.

The programme, which will air later this year, sees Mr Fry complaining about the senselessness of attacking gay people ‘who mean them no harm’.

During the filming of the programme, which also went to Russia, Uganda and America, he met campaigners who said they were able to cure homosexuality and is also seen meeting Elton John and his partner David Furnish.

The BBC, which released a short clip of the programme this week, said in the programme that he confronts outspoken government officials and community leaders ‘who strongly oppose gay rights’.

Mr Fry, when making the admission about the suicide attempt in an interview with fellow comedian Richard Herring , said there was no particular reason for the attempt to kill himse lf.

He had said: ‘Now, you may say, how can anyone who has got it all be so stupid as to want to end it all? That’s the point, there is no “why?” It’s not the right question. There’s no reason.’

Troubled: The popular presenter said his suicide attempt last year had been a 'close run thing'

In his description of the suicide attempt he had said: ‘I am the victim of my own moods, more than most people are perhaps, in as much as I have a condition which requires me to take medication so that I don’t get either too hyper or too depressed to the point of suicide.’

Speaking about the night he had attempted to kill himself last year, he said: ‘It was a close run thing. I took a huge number of pills with a large amount of vodka and the mixture of them made my body convulse so much that I broke four ribs, but I was still unconscious.

‘Fortunately when the producer I was filming with at the time came into the hotel room and I was found in a sort of unconscious state and taken back to England and looked after.’

Fry first disclosed he had contemplated killing himself 18 years ago. He was said to have come close to committing suicide in 1995 after abruptly quitting the West End play Cell Mates, which had suffered critical reviews.

He revealed years later that he almost gassed himself in his car, before fleeing the country and was missing feared dead for a week before he was found to be in Belgium.

Mr Fry has admitted he suffers from bipolar disorder, a condition which sees between 25 and 56 per cent of sufferers making at least one suicide attempt.

After details of the interview became public, Mr Fry used his Twitter account to thank his fans for their supportive messages .

He said: ‘I could only tell truth if asked directly. Now fine. On good meds. Love to you all.’

In the new documentary he is seen wondering: ‘Why would someone bother to attack a group of people who mean them no harm.’

Mr Fry is also seen being told by an anti-gay activist that he had to admit ‘being gay is difficult’. Mr Fry responds by saying ‘not really’ before suggesting that the critic himself had a somewhat ‘metrosexual’ appearance.

Uganda, where Mr Fry was filming, has become famous for its attempts to introduce an anti-homosexuality bill which had originally included the potential punishment of the death penalty in certain cases such as ‘serial offenders’.

The BBC yesterday described the programme as ‘an inspiring story of bravery and resilience’ which celebrated ‘the triumph of love in the face of adversity’.