A petition to the Scottish Parliament demanded a review of the donation rules to let healthy gay and bisexual men give blood.
But Keith Thompson, the national director of the Scottish National Blood Transfusion Service (SNBTS), said its duty was to ensure blood was as safe as possible, and warned that HIV infections in gay men were rising.
The Scottish Government signalled that it backed the ban – at least for the time being.
The refusal to allow gay men to donate blood has been condemned by gay rights campaigners.
While all donations are tested for infections such as HIV, hepatitis B and C and syphilis, a small number of cases will not be detected by these tests. This is because the tests do not pick up very early-stage infections.
The SNBTS said the only defence against this was careful donor selection.
As well as gay men, other groups prevented from giving blood due to the risks from early infection include anyone who has had unprotected sex with a prostitute in the past year; those who have had unprotected sex overseas in a high-risk HIV country, such as in sub-Saharan Africa, in the past year; and those who have had sex with an intravenous drug-user in the past 12 months.
Campaigners are particularly angry over the lifetime ban on gay men and say allowing them to donate blood would help solve the problem of a shortage of lifesaving supplies.
The petition, raised by campaigner Rob McDowall, was supported by gay rights groups, including Stonewall.
Mr McDowall's petition was also backed by the National Union of Students, which branded the rules discriminatory.
Bloodban – a campaign calling for the rules on donations to be changed –said that the current measures were "outdated, stereotypical and discriminatory towards healthy gay men".
But in a written response to Holyrood's public petitions committee, Mr Thompson said about one-third of those blood donations that turned out to be HIV-positive were later found to be from men who had had sex with men.
Despite safe-sex campaigns, HIV infections in men were rising, and 86 per cent of all new infections in Scotland in 2007 concerned men who had sex with men.
Mr Thompson said it was currently not possible for blood service staff to differentiate safely between gay men whose behaviour might leave them at increased risk of HIV and those whose behaviour did not. Calum Irving, the director of Stonewall Scotland, said: "We believe the blood ban is discriminatory and should be lifted, as it has already been in other countries.
"The Blood Transfusion Service is applying one rule for gay people and another for straight people."
A Scottish Government spokeswoman said: "We recognise that many gay men sincerely wish to help patients by giving blood and may be frustrated as a result of this rule. Advances in blood transfusion safety procedures may allow gay and bisexual men to donate in the future but, until then, priority has to be given to securing the safety of the blood supply."
Safety first means series of restrictions
VARIOUS measures are in place to ensure that blood donations are as safe as possible – both for donors and their recipients.
Anyone between the ages of 17 and 66 who is in general good health can volunteer to give blood.
But there are restrictions if there are fears that someone's blood could transmit an infection to whoever receives it.
Among those banned from giving blood for this reason are people who have visited a foreign country within the past 12 months where they may have been exposed to malaria.
There is also a ban on donations from people who have ever injected drugs, because of the higher risk they face from picking up an infection.
The Scottish National Blood Transfusion Service also prevent donations from people whose lifestyle puts them at risk of HIV or hepatitis infection, such as those who have had unprotected sex with a prostitute in the last year.
People who have had an ear or body piercing or a tattoo within the past year are also stopped from donating because they may be more likely to have been exposed to infections.
And due to fears about vCJD – for which there is currently no test – anyone who has received a blood transfusion in the UK since 1980 is not allowed to donate.
This followed a case of someone contracting the disease through a blood transfusion.