A federal appeals court on Friday allowed a lawsuit to go forward challenging the U.S. military’s decision to discharge certain service members who test HIV-positive, saying it appears the Pentagon unlawfully discriminates against them based on a medical condition.

The unanimous decision by a three-judge panel of the Richmond-based U.S. Court of Appeals for the 4th Circuit marked a setback for the Pentagon, which has sought to toss out the lawsuit by two airmen whom the Air Force moved to force out after the results of health screenings last year.

The Defense Department restricts newly diagnosed personnel from deploying to combat zones such as Afghanistan. The government asserts that the risk of HIV transmission is heightened on the battlefield, where it may be more difficult to maintain treatment.

But in arguments in September, judges asked why the military would refuse to deploy service members with HIV but not those with other chronic conditions such as diabetes and high blood pressure.

Writing for the panel, U.S. Circuit Judge James A. Wynn Jr. said plaintiffs were likely to show the military acted “arbitrarily or capriciously” in violation of the Administrative Procedures Act by discharging service members without an individualized fitness assessment.

“A ban on deployment may have been justified at a time when HIV treatment was less effective at managing the virus and reducing transmission risks,” Wynn wrote in the 46-page opinion. “But any understanding of HIV that could justify this ban is outmoded and at odds with current science. Such obsolete understandings cannot justify a ban, even under a deferential standard of review and even according appropriate deference to the military’s professional judgments.”

The appeals court was hearing the Pentagon’s challenge to a February ruling by Judge Leonie M. Brinkema of the U.S. District Court in Alexandria, who temporarily blocked the military from enforcing its policy nationally. She chastised the government for providing “no evidence, whether anecdotal or otherwise, of the effect of HIV on a service member’s medical fitness or the military’s readiness.”

Lawyers for the two discharged plaintiffs, identified in court papers by the aliases Richard Roe and Victor Voe, assert that at least four other active-duty Air Force members face discharge because of the restrictions and that hundreds of others could be affected by the policy.

A separate pending case in Virginia challenges the Army’s similar HIV-related policy.

Those diagnosed with HIV are still prohibited from joining the military.

“Today’s ruling clears the way for us to definitively prove at trial that a person living with HIV can perform the job of soldier or airman as well and as safely as anyone else,” said Scott Schoettes, Counsel and HIV Project Director at Lambda Legal, which filed the suit with the Modern Military Association of America and pro bono co-counsel Winston & Strawn. “We are confident Roe and Voe will succeed because the government is unable to offer a reasonable justification for their discriminatory treatment of service members living with HIV.”

Officials with the Justice Department and Department of Defense could not be immediately reached for comment.

Justice Department lawyers had urged the panel to reverse Brinkema’s ruling and to defer to military leaders’ decisions regarding “the amount of risk to tolerate and who to send to the battlefield.”

Former defense secretary Jim Mattis had made it a priority to trim the number of service members unable to deploy with a policy known as “deploy or get out.”

Justice Department lawyer Lewis S. Yelin also told the court that although the risk of transmission is low, “it is not nonexistent.” The policy accounts for the “rigors and chaos” of combat that heighten the risk of blood-to-blood contact or a disruption in the supply of necessary medicine, Yelin said.

But the court panel, which included judges Henry F. Floyd and Albert Diaz, said that contrary to the government’s claims that HIV treatment would be disrupted by “austere conditions” of deployment, three-quarters of HIV-positive individuals take a single daily pill that tolerates extreme conditions and produces minimal side effects.

Routine testing can be conducted on-site or via a sample at a lab, the court said, adding, “whether testing is needed once or twice every year, the treatment is not ‘highly specialized.’ ”

The panel also said the government record failed to support the risk of HIV transmission through blood transfusions and blood exposure on the battlefield, citing transfusion requirements, procedures and testing, as well as data on HIV transmission rates.

“The Government’s justifications for a categorical ban … do not account for the Plaintiffs’ persuasive and credible evidence — evidence available to the Government when it enacted this policy — on HIV treatment and transmission risk,” Wynn wrote.

The judges also cited a military study of 1.13 million Army service members deployed in Afghanistan and Iraq between 2001 and 2007, including 131 who tested positive after previously testing negative.

“The study identified only one case of a service member who was infected with HIV during deployment,” the opinion stated, and “no instances of transmission through trauma care, blood splash, transfusion, or other battlefield circumstances.”

Wynn noted the support of former military officials who backed the airmen in court filings, including Ray Mabus, who was secretary of the Navy; Eric K. Fanning, who was secretary of the Army; and Deborah Lee James, who was secretary of the Air Force.

Echoing filings from the former military officials supporting the airmen who filed suit, Wynn wrote, “‘there is no legitimate reason to deny HIV positive service members the opportunity to deploy.’ ”