RICHMOND — Federal judges pressed the Defense Department on Wednesday to justify the U.S. military’s refusal to deploy — and decision to discharge — certain service members who test HIV-positive.

A lawsuit was filed by two airmen slated to be forced out of the Air Force after their results during health screenings last year. The Pentagon’s policy, they say, unlawfully discriminates against service members based on a medical condition.

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

The Richmond-based U.S. Court of Appeals for the 4th Circuit was reviewing an earlier ruling from federal court in Alexandria that temporarily blocked the military from enforcing its policy nationally and from discharging the two airmen, identified in court papers by the aliases Richard Roe and Victor Voe.

At least four other active-duty Air Force members face discharge because of the restrictions and hundreds of others could be affected by the policy, according to lawyers for the two. A separate pending case in Virginia challenges the Army’s similar HIV-related policy.

In court Wednesday, Judge James A. Wynn Jr. 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.

Judge Henry F. Floyd, too, wanted to know, “What’s the bottom-line reason they couldn’t be deployed?”

Justice Department lawyer Lewis S. Yelin told the court that although the risk of transmission is low, “it is not nonexistent” and that 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.

Wynn seemed concerned that the policy has become more restrictive in the past two years despite the low risk of transmission with treatment. The government, Wynn said, “makes it sound like it’s a really big deal. One of these men is only taking one pill a day.”

After the two men tested positive, doctors determined they were physically fit to deploy and their commanding officers backed their continued service. But last November they were told they would be discharged.

The Air Force concluded that the men could no longer perform their duties because officials said their medical condition prevented them from deploying to the areas where most airmen are expected to go.

The appeals court was reviewing a February ruling by Judge Leonie M. Brinkema of the U.S. District Court in Alexandria, who chastised the government for providing “no evidence, whether anecdotal or otherwise, of the effect of HIV on a servicemember’s medical fitness or the military’s readiness.”

The two men, who have each worked more than five years in logistics and maintenance roles, were not offered alternative jobs, which they said they would have accepted rather than facing discharge. The court injunction has allowed them to remain in their posts pending trial.

Justice Department lawyers urged the appeals court in filings to reverse the earlier ruling and to defer to the nation’s military leaders when it comes to deciding “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.”

Attorney Geoffrey P. Eaton, representing the airmen with the LGBT military association Modern Military Association of America and Lambda Legal, told the court Wednesday that the policy violates the Air Force’s own rules prohibiting discharge based solely on HIV status.

The third judge on the panel, Albert Diaz, asked Eaton why the military’s policy is irrational in light of the unique combat environment.

“Isn’t the military entitled to make judgments about risks?” Diaz asked.

Eaton said the military’s “categorical bar” for service members like the two airmen ignores advances in medical treatment. “The military’s regulations are going in the wrong direction,” he said. “They are no longer justified.”

A group of former military officials backed the airmen in court filings, saying there is no justification for preventing HIV-positive service members from deploying. The policy, they said, is outdated and without scientific support.

“The latest medical expertise and our own collective military experience show that these risks are more theoretical than actual,” according to the brief joined by the military officials, 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.

“Even if such risks exist to some small extent, they do not justify categorically discharging service members who in all other respects are fit to serve. It is more damaging to military readiness to deny those service members the opportunity to deploy where they are needed,” the brief stated.