By ADAM LIPTAK

April 22, 2013

WASHINGTON — The question for the Supreme Court on Monday was whether groups receiving federal money to combat AIDS abroad may be required to adopt policies opposing prostitution. The answer, judging from the justices’ comments in the first half of the argument, seemed to be that the First Amendment bars attaching that kind of condition to federal grants.

“There have to be some limitations on what type of loyalty oath you can require them to sign,” said Chief Justice John G. Roberts Jr.

Justice Samuel A. Alito Jr. said that allowing the government to compel speech is “a dangerous proposition.” Justice Ruth Bader Ginsburg, too, was skeptical about “requiring somebody to say ‘I believe this’ or ‘I agree with the government on that.’ ”

The Run-Up

The podcast that makes sense of the most delirious stretch of the 2016 campaign.

But what seemed like a consensus disintegrated as the argument progressed and the justices started to sort through what conditions might be permitted by the First Amendment. Thanks to a tenacious argument by a government lawyer, concessions by a lawyer challenging the 2003 law requiring the anti-prostitution policy and probing hypothetical questions from the justices, what looked like an easy case at the outset grew more complicated.

Chief Justice Roberts asked whether the government could have required groups receiving money for water projects in South Africa years ago to adopt policies opposing apartheid. The question elicited a long pause from David W. Bowker, a lawyer for groups challenging the law.

Mr. Bowker said the anti-apartheid condition might pass First Amendment muster if it could be shown to be related to the groups’ ability to do their work.

The Supreme Court’s precedents on so-called unconstitutional conditions are confusing, and Mr. Bowker tried to walk a series of fine lines. He said the government was free to finance some programs and not others, and conceded that the government may control the speech of groups accepting money as long as it was in connection with their work on the programs.

The flaw in the 2003 law, Mr. Bowker said, was in “requiring that they profess a personal belief, and refrain from certain private speech outside the context of the government program.”

In 2011, a divided three-judge panel of the United States Court of Appeals for the Second Circuit, in New York, blocked the law, saying it “compels grantees to espouse the government’s position on a controversial issue.” The full appeals court declined to rehear the case.

Mr. Bowker said his clients neither promoted prostitution nor approved of it. “They would like to be free to engage in this important discussion,” Mr. Bowker said of his clients, “and to be unfettered by a policy requirement that demands fealty to the government’s viewpoint.”

Sri Srinivasan, a deputy solicitor general whose nomination to the United States Court of Appeals for the District of Columbia Circuit is pending, gave the justices several guideposts. The conditions must be germane, he said. Using government money to suppress a viewpoint is not permissible, but the government should be free to choose between groups that share its policy goals and those that oppose them.

Several justices tested those limits with questions about higher education, recycling and teenage pregnancy. Justice Alito, perhaps the most skeptical of the law, asked whether groups receiving money under a health care law could be made to take a stance on the availability of guns.

Mr. Srinivasan said that if “the requisite germaneness” were satisfied and the government’s goal was not to suppress disfavored speech, such a condition might be permissible. He seemed to make headway by characterizing the required pledge as a selection criterion rather than an effort to force groups to adopt views they did not hold.

Echoing the point, Chief Justice Roberts asked Mr. Bowker why the government would “want to sign up with somebody who didn’t share the objectives of the program.” Mr. Bowker responded that it would be problematic to deny financing based on a group’s viewpoint.

Justice Antonin Scalia disagreed. “They can’t fund the Boy Scouts of America because they like the programs that the B.S.A. has?” Justice Scalia asked. “They have to treat them equivalently with the Muslim Brotherhood? Is that really what you’re suggesting?”

Mr. Bowker said the government had not articulated a meaningful limiting principle.

“On the government’s theory,” he said, “the government can give anyone in the country a dollar in Medicare funds and say, O.K., now that you’ve taken a dollar of our money, we want you to profess your agreement with the Affordable Care Act, and we want you to never say anything inconsistent with that in your private speech.”

Justice Elena Kagan recused herself from the case — United States Agency for International Development v. Alliance for Open Society International, No. 12-10 — presumably because she had worked on it as United States solicitor general.