WASHINGTON — The Supreme Court sounded closely and sharply split Tuesday on whether to declare that gays and lesbians have a constitutional right to marry.

Justice Anthony M. Kennedy, who is widely expected to be the deciding vote in the matter, did not tip his hand, giving hope to both sides of the debate.

Early in the oral arguments before the justices, Kennedy noted that the institution of marriage had been defined for “millennia” as the union of a man and a woman. “It’s very difficult for the court to say, oh well, we know better,” he said.

But later, he told a Michigan lawyer fighting to uphold that state’s refusal to recognize gay marriage that the bond between children and their parents is crucial, and that can include children raised by same-sex couples.

He said it was “the wrong premise” to assume that children benefit only from being raised by parents of the opposite sex.

Overall, Tuesday’s arguments indicated the justices remain split over gay marriage, even as opinion polls show a majority of Americans support the idea.

The court’s four conservatives made clear they were prepared to uphold state laws in Michigan, Ohio, Kentucky and Tennessee that deny marriage rights to same-sex couples.

Chief Justice John G. Roberts Jr. said the gay couples are effectively asking the court to “redefine” the institution of marriage. “You are not seeking to join the institution. You are seeking to change it,” he told attorney Mary L. Bonauto, who was arguing on behalf of same-sex couples.

The court’s four liberal justices sounded just as the convinced that states had no legal justification to exclude same-sex couples from marrying.

“We are not taking anyone’s liberty away” by allowing gay couples to marry, said Justice Sonia Sotomayor.

Justice Stephen Breyer said the court has repeatedly ruled that Americans have a fundamental right to marry, and that right cannot be denied for “purely religious reasons,” he said.

Kennedy criticized a state attorney who said laws against gay marriage do not involve recognizing the “dignity” of committed couples.

“I don’t understand your argument,” he said. His 2013 opinion in a case striking down part of the federal Defense of Marriage Act repeatedly said the government may not demean the “dignity” of same-sex couples who had married.

But Kennedy’s back-and-forth comments during the arguments left at least some doubt about whether he is prepared to rule now that same-sex marriage is a constitutional right.

As arguments opened, the justices struggled with the way homosexuality and marriage have been viewed throughout time, an unusual perspective for judges who generally look back to the writing of the U.S. Constitution just over two centuries ago.

“You are asking us to decide it for this society when no other society had it (gay marriage) before 2001?” asked Justice Antonin Scalia, referring to legalization of gay marriage in the Netherlands.

Roberts said that a decision now institutionalizing gay marriage would close debate on the issue.

“If you prevail here, there will be no more debate, and closing debates means closing minds,” Roberts said.

Bonauto, who lives in Portland, Maine, stressed that serious rights are being compromised in many states and that it would not be fair to tell gay couples to “wait and see.”

The justices now must decide whether to resolve the national debate over gay marriage this year with a clear constitutional ruling, or instead leave the matter to be decided in each state by their voters or legislators.

Bonauto, a pioneer in the legal struggle for gay marriage, won the first pro-gay-marriage ruling before the Massachusetts high court, and she launched the successful legal attack on the Defense of Marriage Act that denied benefits to legally married gay couples.

She is representing two Michigan nurses who are raising four foster children they have adopted.

She was joined by U.S. Solicitor Gen. Donald Verrilli Jr. representing the Obama administration.

The outcome is likely to be close.

Two years ago, the court struck down part of the Defense of Marriage Act by a 5-4 vote.