WASHINGTON — The Supreme Court on Friday upheld a provision of the Affordable Care Act that requires insurance companies to offer some kinds of preventive care for free.

In a 6-3 decision, written by Justice Brett Kavanaugh, the majority ruled that a federal task force that determines which preventive health measures insurance companies must cover at no cost to the insured was constitutional.

The decision appears to safeguard coverage for tens of millions of Americans who receive some free health care services, including cancer and diabetes screenings, medications to reduce heart disease and strokes, and eye ointment for newborns to prevent infections causing blindness.

Chief Justice John Roberts and Justice Amy Coney Barrett, as well as the liberal wing — Justices Sonia Sotomayor, Elena Kagan and Ketanji Brown Jackson — joined the majority opinion.

The remaining conservative justices, Clarence Thomas, Samuel Alito and Neil Gorsuch, dissented.

Mitchell Warren, the executive director of an HIV prevention organization, AVAC, praised the decision, calling its outcome a relief.

“Preventive services across health care are cost-saving and lifesaving, and I am grateful that the Supreme Court found on the side of evidence, logic, public health and human rights,” he said.

The case is the latest lawsuit targeting the Affordable Care Act, President Barack Obama’s central legislative achievement. The heath care law survived three previous major challenges at the Supreme Court, in 2012, 2015 and 2021. Roberts cast the decisive vote to save the law in 2012.

The dispute decided on Friday centered on the U.S. Preventive Services Task Force, a panel of experts in the Department of Health and Human Services that recommends preventive medical services, including screenings and medications to prevent serious diseases.

The task force was devised to determine preventive health services that insurance companies are required to offer for free under the Affordable Care Act.