The criminalisation of adult sexual behaviour and the violation of the human rights of people living with HIV are hampering HIV responses across the world.
UNAids urges countries to remove laws and policies that make it difficult for people to access HIV prevention and treatment and adopt laws that protect people from discrimination, coercion and monitoring of their private lives.
Recently a number of countries and local bodies considered a range of legal measures, such as making homosexuality a crime, using technology to trace the movements of people living with HIV, mandatory testing and forced rehabilitation of sex workers and people addicted to drugs.
Such measures have a negative effect on delivering HIV prevention programmes and access to treatment. Not only do they violate human rights but further stigmatise people.
UNAids executive director Peter Piot said: "Homophobia - in all its forms - is one of the top five barriers to ending this epidemic worldwide.
"If communities, NGOs, governments and international organisations don't respect and promote the rights of people with diverse sexuality we will not end Aids."
All forms of restrictions, whether limiting people's ability to travel, monitoring movements or criminalising transmission of HIV, are not based on sound public health practices.
It can alienate people living with HIV from society and facilitate further transmission of HIV. Laws that reduce stigma and discrimination, protect privacy and promote gender and sexual equality help save lives.
Only 26percent of countries report having laws that protect homosexuals and 84 countries have legislation that prohibits same-sex relationships. Countries that have nondiscrimination laws have achieved higher rates of coverage of HIV prevention efforts.