In May, Gilead said it would donate enough medication to supply 200,000 patients with the drug for up to 11 years. But about 1 million Americans are estimated to be at risk for infection, and only about 270,000 people take the pills.

Gilead makes more than $3 billion a year on Truvada.

The lawsuit was cheered by some activists. PReP4All, a group that has pushed for wider access for the drugs, called it “a necessary first step to ensure access to effective H.I.V. prevention for everyone who needs it.”

“For nearly a decade, Gilead’s price gouging on PrEP has prevented hundreds of thousands of Americans from accessing this life saving medication, despite it being a taxpayer-funded invention,” the group said in a statement. “If H.H.S. is truly invested in ending the H.I.V. epidemic, it will use these patents as leverage to ensure that everyone who needs PrEP can get it.”

Gilead did not respond to a request for comment sent on Monday, but has previously said that the government’s patent claims are invalid, and that others had conceived of the concept of PrEP before the government. The Department of Health said hundreds of millions of dollars in taxpayer money went into research that led to the government patents. Currently, Truvada and Descovy are the only F.D.A.-approved drugs for H.I.V. prevention.

Descovy, approved in October, contains a new version of tenofovir, the active ingredient in Truvada, and was expected to effectively replace Truvada. But the approval excluded “individuals who have receptive vaginal sex,” as Gilead tested it only in men and transgender women. The F.D.A. will require the company to study the drug on cisgender women.