Lawyers reached a deal on Monday to keep the Affordable Care Act’s mandate requiring health plans to cover preventive care at no cost to patients.

A district court in Texas ruled in March that part of the requirement was unconstitutional. The decision took effect immediately, meaning insurers no longer had to cover certain types of preventive care, including a pill to prevent the spread of H.I.V.

The Fifth Circuit Court of Appeals temporarily stayed the ruling last month, bringing the health law’s provision back into effect. The appeals court also asked the two parties — a group of Texas residents and businesses challenging the law, and the Biden administration, which is defending it — to come to a compromise on how much of the mandate should be put on hold while it weighed its decision.

The deal they reached leaves the provision almost fully in tact, requiring a vast majority of health plans to continue providing preventive care at no charge. The agreement includes an exemption for the small businesses and individuals challenging the provision; these entities will be allowed to use a plan that does not cover all preventive services if they can find a health insurer who offers it.

The appellate court, which is expected to rule on the preventive care mandate’s constitutionality later this year, still has to approve the lawyers’ agreement.

Health policy experts describe the mandate as one of the most transformative policies of the health law, known as Obamacare, because it could prevent worsening disease and higher costs later on. It is also popular, with 62 percent of the public recently saying it was “very important” that it stay in place.

Before the Affordable Care Act’s passage, in March 2010, patients sometimes faced big bills for preventive care such as birth control or colonoscopies. Since the mandate took effect, studies have shown, more Americans have received blood pressure screenings, cholesterol screenings and flu vaccines.

In March, Judge Reed O’Connor of the Federal District Court for the Northern District of Texas ruled that part of the mandate was unconstitutional because an independent panel advising the government on what benefits to cover did not have the proper authority to do so.

Judge O’Connor’s ruling did not undo the entire preventive services mandate, but said it should not cover services that the panel, the United States Preventive Service Task Force, had recommended since 2010.

The newer services included three types of screenings: one for anxiety in children, another for unhealthy drug use and a third for weight gain in pregnant women. The mandate also included a recommendation that people at high risk for H.I.V. take PrEP, a daily pill that is highly effective at preventing the transmission of the virus.

The challengers in this case objected to covering PrEP, in particular, contending that the drug could “encourage homosexual behavior or intravenous drug use.”

The deal may not have much practical impact on most Americans. When the initial ruling from the district court came down in March, many health plans announced that they would not change their benefits.

Health plans typically have policies that span a full year, and it is unusual for them to change their members’ benefits in the middle of a contract. And insurers may be reluctant to take away a popular benefit that, in some cases, saves them money by preventing serious disease later on.

Matt Eyles, the president of AHIP, the trade group representing health insurers, said in a statement shortly after the initial ruling that there would be “no immediate disruption in care or coverage.”

The Blue Cross Blue Shield Association, which has health plans across the country, said in March that it would “strongly encourage their members to continue to access these services to promote their continued well-being.”