Drug-injecting addicts who took a daily antiretroviral pill were half as likely to become infected with H.I.V. as those who did not, a major new study has found, providing the final piece of evidence that such treatments can prevent AIDS in every group at risk. Earlier clinical trials showed that the therapy can sharply reduce the risk of H.I.V. transmission from mother to child, and in gay and bisexual men and heterosexuals.

“This provides the totality of the evidence that the drugs used to treat the infection are also very effective at preventing it,” said Dr. Salim S. Abdool Karim, a prominent South African AIDS researcher who wrote a commentary in The Lancet, which published the new study on Wednesday.

The accumulating evidence from clinical trials means antiretroviral drugs are increasingly seen as another in the arsenal of weapons to prevent AIDS, along with condoms, abstinence and fidelity; early antiretroviral treatment; male circumcision in Africa; microbicide gels; and other options.

The formal results of the study, which involved 2,400 drug users in Thailand, showed that taking tenofovir pills — a therapy known as pre-exposure prophylaxis, or PrEP — reduced infections by 49 percent. Addicts who took the pills regularly, based on measures of tenofovir in their blood, did much better: They were 74 percent less likely to become infected.

“This is an exciting day,” said Dr. Jonathan Mermin, director of H.I.V. prevention for the Centers for Disease Control and Prevention in Atlanta. “This culminates a decade of PrEP research.”

Prophylaxis usually involves taking a daily pill of tenofovir or tenofovir plus another drug, but can also include antiretroviral-laced vaginal gels used before sex and the use of various antiretroviral drugs by infected mothers just before they give birth.

The potential impact of the treatment for drug addicts is greatest in Eastern Europe and Central Asia, where they account for up to 80 percent of infections. Many countries in those regions, for religious and political reasons, outlaw proven tactics like handing out clean needles or offering methadone or other needle-free opioid substitutes.

About 10 percent of the new infections in the world — and about 8 percent of those in the United States — are thought to result from needle sharing.

The new five-year study was run by Thai researchers with C.D.C. support through 17 Bangkok drug-treatment clinics. Addicts are notoriously unreliable about keeping clinic appointments and have been known to sell even lifesaving drugs, so the participants were offered modest payments to take their daily pills under the eyes of a nurse. They got $8.75 for each month they stayed in the trial, plus $8.75 for each week they showed up all seven days, plus $1.90 each day they appeared. Those who came in only monthly were paid to keep drug-use diaries.

“We should be under no illusions that these were real-world settings,” said Mitchell Warren, executive director for AVAC, an organization that lobbies for AIDS prevention.

On paper, 87 percent of all drugs were scheduled to be taken daily under observation, but some patients were much more consistent than others; women and addicts older than 40 did better.

Now that it is clear that the medications work, Mr. Warren said, new studies must work out how best to motivate unpredictable drug users to take them.

Dr. Julio Montaner, a University of British Columbia AIDS researcher who works with a large addict population in Vancouver, said the news that the therapy worked among drug users was “all very good and dandy — and a new piece to the puzzle.”

But he said he worried that it would compete for limited government health budgets with tactics that he were already proven: clean needles, methadone and test-and-treat, which involves hunting aggressively for all who are infected in a city and putting them on antiretroviral treatment immediately, which makes them 96 percent less likely to infect anyone else.

But Dr. Mermin of the C.D.C. said: “I think we’ve moved beyond competition between prevention and treatment. Even this is not for everybody.”

The United States is setting up studies, he said, to see which anti-H.I.V. tactics work best in different neighborhoods and different risk groups.

The new study may affect individual doctors’ decisions. For example, a doctor with an uninfected patient known to inject drugs might choose to put that patient on daily tenofovir, just as some doctors do with uninfected but promiscuous gay male patients, or uninfected patients with infected regular sex partners.

Exactly how the tenofovir protected the participants cannot be known, Dr. Karim pointed out, because many addicts both share needles and sell their bodies to get money for drugs, so they engage in two risky behaviors.

Given how fast AIDS shot through various risk groups when it first appeared in the 1980s, researchers have long assumed that injecting blood and sharing needles was the riskiest behavior, followed by anal sex, then vaginal sex — but there is little data to prove that.

For that reason, some researchers thought it unlikely that pre-exposure prophylaxis would protect drug addicts, and they were pleasantly surprised it worked fairly well.

Exactly how well it works in any risk group depends on how study results are analyzed, but it seems to be roughly as protective for drug users as it is for gay men, and about as protective as circumcision is for heterosexual men in Africa.

According to the C.D.C., when study results are adjusted to include only participants who took their pills most of the time, the protective effects are 92 percent for gay men, nearly 90 percent for couples in which only one partner is infected, 84 percent for heterosexual men and women, and about 70 percent for drug injectors.

Two trials done in heterosexual women, known as Fem-PrEP and Voice, were stopped early because women receiving drugs and those given placebos were getting infected at similar rates. Later analysis of the results showed that many of the women had not been taking their drugs. Some said they did not believe they were at risk, and others said that if they had bottles of antiretroviral medicines in their homes, their families and potential lovers would assume they were infected and shun them.

But single heterosexual women in another trial, conducted in Botswana and known as TDF2, were protected.

A version of this article appears in print on June 13, 2013, on page A11 of the New York edition with the headline: Study of Drug Users Affirms Pill Prevents H.I.V. in All Risk Groups. Order Reprints|Today's Paper|Subscribe