WASHINGTON (CNN) - The Supreme Court has ruled the federal government may not deny funds from its global anti-AIDS program to organizations that refuse to actively oppose prostitution.
In a 6-2 decision on Thursday, the justices determined the policy requiring fund recipients adhere to a larger message about fighting disease and its root causes was not directly related to the "core" mandate of the AIDS program.
Chief Justice John Roberts, who wrote the opinion for the majority, said the 2003 law violated the First Amendment. The ruling tosses out the policy.
The case was closely watched by many U.S.-based non-governmental organizations that distribute financial and other assistance overseas.
The decision comes as the justices work toward wrapping up a busy term, likely next week.
Among the big issues yet to be resolved: affirmative action in college admissions; federal enforcement of the Voting Rights Act; and the politically blockbuster constitutionality of same-sex marriage.
The court next meets in public session to release decisions on Monday.
Looking at the case decided on Thursday, the Leadership Act was designed to "make the reduction of HIV/AIDS behavioral risks a priority of all prevention efforts."
In addition to promoting abstinence, monogamy, counseling, and the use of condoms, the law sought to use U.S. funds to "educate men and boys about the risks of procuring sex commercially" as well as finding ways to help "commercial sex workers" themselves get out of the business.
Federal money came with two conditions, including the "Policy Requirement"-- a ban on "assistance to any group or organization that does not have a policy explicitly opposing prostitution and sex trafficking."
Several groups objected to what they called a "loyalty oath," including the U.S.-based Alliance for Open Society and Pathfinder International.
Roberts said the policy could not be sustained.
"The (requirement) compels as a condition of federal funding the affirmation of a belief that by its nature cannot be confined within the scope of the government program," he wrote. "In doing so, it violates the First Amendment and cannot be sustained."
Explaining further, Roberts noted in most cases "if a party objects to a condition on receipt of federal funding, its recourse is to decline the funds."
But the ruling concluded the law improperly prevented aid recipients from disavowing the government's wishes when spending its own money.
"The (requirement) goes beyond preventing recipients from using private funds in a way that would undermine the federal program. It requires them to pledge allegiance to the government's policy of eradicating prostitution," Roberts wrote.
The anti-prostitution pledge in the law would still apply to organizations based outside the United States receiving U.S. funds.
Justices Antonin Scalia and Clarence Thomas dissented. Justice Elena Kagan had earlier recused herself from the case, because she had supervised the government's legal response when she was the Justice Department's Solicitor General under President Obama from 2009-2010.
Serra Sippel, president of the Center for Health and Gender Equity, said there is "no place for discrimination" today.
"Discriminatory policies like the anti-prostitution pledge keep us from ever getting ahead of HIV," Sippel said.
The case is Agency for International Development v. Alliance for Open Society International (12-10).