The US Supreme Court on Thursday struck down as a violation of free speech a portion of a 2003 federal law that required recipients of government money in an international anti-AIDS program to embrace and advocate a US policy explicitly opposing prostitution.

In a 6-to-2 decision the high court ruled that the government-imposed requirement violated the First Amendment by forcing US aid recipients to adopt a position that extended beyond the administration of the anti-AIDS program.

“The policy 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,” Chief Justice John Roberts wrote in the majority opinion.

He quoted former Justice Robert Jackson’s famous opinion in a landmark First Amendment case: “If there is any fixed star in our constitutional constellation, it is that no official, high or petty, can prescribe what shall be orthodox in politics, nationalism, religion, or other matters of opinion or force citizens to confess by word or act their faith therein.”

In a dissent, Justices Antonin Scalia and Clarence Thomas said the government was free to seek out those who agree with its ideas and enlist their assistance in effectively spending government money to achieve its goals.

“In the end, and in the circumstances of this case, compelling as a condition of federal funding the affirmation of a belief is no compulsion at all,” Scalia said.