By Apoorva Mandavilli / The New York Times

The United Nations on Tuesday adopted new targets for ending AIDS as a public health threat by 2030, seemingly a goal most countries could easily have agreed to. But consensus had been elusive.

In early negotiations over the agreement, called a political declaration, the United States and the European Union fought to ban policies and laws that stigmatize, or even criminalize, high-risk groups — and drastically scaled back moves to relax patent protections for H.I.V. drugs.

The U.N. declaration sets priorities for the global AIDS response and guides policies at a national level. It also gives global health groups and civil society organizations leverage to pressure governments to honor their commitments.

On Monday, Dr. Kavanagh and his colleagues published new work showing that countries that criminalize same-sex relationships, drug use and sex work have had much less success in turning back H.I.V.