WASHINGTON  The Supreme Court struggled Monday with whether a state-run law school may refuse to recognize a religious student group that excludes gay students and non-Christians.

"Why doesn't this just all work out?" Justice Anthony Kennedy asked in frustration about why the conflict is before the court in the first place. "If the Christian Legal Society has these beliefs, I am not so sure why people that don't agree with them want to belong to them."

The case pits a university's interest in safeguarding students from discrimination against a religious group's interest in preserving its identity and message by limiting participation.

In some respects, the justices appeared divided along ideological lines. Liberal-leaning justices such as Ruth Bader Ginsburg sympathized with the anti-bias goals of the University of California-Hastings College of Law, and more conservative justices such as Samuel Alito seemed inclined toward the students.

As often happens on this divided bench, centrist conservative Kennedy appeared to be in the middle. Yet he and others, such as Justice Stephen Breyer, also questioned whether the case had been sufficiently developed in lower courts to allow the justices to resolve the students' claim that Hastings targeted their particular views.

The dispute began when Hastings officials declined to recognize the Christian Legal Society (CLS) chapter — and give it student-activity funding, meeting space and other privileges — based on the group's refusal to let gay students and non-Christians fully participate. The chapter group sued, saying its members had a First Amendment right to limit participation to people who subscribe to their beliefs, including a ban on homosexual relations. Lower courts rejected their claim, accepting Hastings' stance that its policy prevents bias.

Stanford University law professor Michael McConnell, representing the CLS chapter, told the justices that making groups admit students who do not accept their message is a "frontal assault on freedom of association."

"If Hastings is correct, a student who does not even believe in the Bible is entitled to demand to lead a Christian Bible study," McConnell insisted.

Justice Sonia Sotomayor tested the scope of McConnell's argument: "Are you suggesting that if a group wanted to exclude all black people, all women, all handicapped persons," she asked, "that a school has to accept that group and recognize it, give it funds?"

McConnell said no, that the CLS chapter was arguing only that it should be able to keep people from fully participating based on their contrary beliefs.

"Note how destructive an 'all-comers' policy directed toward beliefs would be," McConnell added, saying that an NAACP chapter would have to allow in "a racist skinhead."

Ginsburg said claims about "sabotage" by outsiders were not backed up by evidence.

Hastings' lawyer Gregory Garre argued that all student groups must abide by the open-membership policy and that the Christian students were not being singled out.

Justice Antonin Scalia was dubious of that claim and said, "To require this Christian society to allow atheists not just to join but to conduct Bible classes ... that's crazy."

Alito suggested the Hastings policy would require a Muslim group to admit "students who hate Muslims ... and want to take over that group."

A ruling is likely by the end of June, when the justices usually recess for the summer.

To report corrections and clarifications, contact Standards Editor Brent Jones. For publication consideration in the newspaper, send comments to letters@usatoday.com. Include name, phone number, city and state for verification. To view our corrections, go to corrections.usatoday.com.

Guidelines: You share in the USA TODAY community, so please keep your comments smart and civil. Don't attack other readers personally, and keep your language decent. Use the "Report Abuse" button to make a difference. Read more.