The Supreme Court has ruled that a government regulation that forced groups that fight AIDS abroad to oppose prostitution if they wanted federal funding. The court said that the law violated the First Amendment.

According to The New York Times, the 2003 law at the center of the case said that private groups that raised money for the fight against HIV/AIDS abroad must show that they have “a policy explicitly opposing prostitution.” However, this law only applied specifically to anti-AIDS groups.

In a 6-2 ruling, the court said that this pledge violates the First Amendment right to Free Speech by forcing a private group to agree with the government. Justice Elena Kagan recused herself, while Justice Antonin Scalia and Justice Clarence Thomas dissented.

“The policy requirement goes beyond preventing recipients from using private funds in a way that would undermine the federal program,” Chief Justice John Roberts wrote, reports USA Today. "It requires them to pledge allegiance to the government's policy of eradicating prostitution.”

“The First Amendment does not mandate a viewpoint-neutral government,” Scalia argued.

Agencies that argued against the policy said that that it would restrict their ability to help in brothels and was counter-productive.

The ruling is the latest from the Supreme Court’s current term. The Court is expected to make rulings on the Defence of Marriage Act and California’s Proposition 8, which should be out next week.