WASHINGTON — The Food and Drug Administration announced Tuesday that it would scrap a decades-old lifetime prohibition on blood donation by gay and bisexual men, a major stride toward ending what many had seen as a national policy of discrimination.

However, the agency will continue to ban men who have had sex with a man in the last year, saying the barrier is necessary to keep the blood supply safe, a move that frustrated rights groups that were pushing for the ban to be removed entirely.

The F.D.A. enacted the ban in 1983, early in the AIDS epidemic. At the time, little was known about the human immunodeficiency virus, which causes the disease, and there was no quick test to determine whether somebody had it. But science — and the understanding of H.I.V. in particular — has advanced in the intervening decades. On Tuesday the F.D.A. acknowledged as much, lifting the lifetime ban but keeping in place a block on donations by men who have had sex with other men in the last 12 months.

The F.D.A. rules on blood donation generally include very wide margins of error. For example, it bars anyone who has traveled in areas where malaria is common from giving blood for a year, even though malaria symptoms are almost unmistakable — chills and fever — and virtually always appear within 40 days. The agency also has a 12-month waiting period for heterosexuals who, among other activities, have sex with prostitutes or with people who inject drugs.