On the day that same-sex unions became legal in Alabama, local officials in dozens of counties on Monday defied a federal judge’s decision and refused to issue marriage licenses to gay couples, casting the state into judicial chaos.

Gay couples were able to get licenses in about a dozen places, including Birmingham, Huntsville and a few other counties where probate judges complied with the judge’s decision. The U.S. Supreme Court ruled early Monday that it would deny Alabama’s request to put the marriages on hold.

But in the majority of counties, officials said they would refuse to license same-sex marriages or stop providing licenses altogether, confronting couples — gay and heterosexual — with locked doors and shuttered windows.

Many of the state’s 68 probate judges mounted their resistance to the federal decision at the urging of the firebrand chief justice of the Alabama Supreme Court, Roy Moore. He is best known for refusing more than a decade ago to comply with a court order to remove a monument to the Ten Commandments from the state Supreme Court’s offices.

In Mobile, about 10 gay couples who had expected to be granted licenses first thing in the morning found the marriage-license window closed indefinitely.

“We’re disgusted with it, but we’re dealing with it,” said Jim Strawser, 51, who with his partner, John Humphrey, had mounted the successful legal challenge against Alabama’s ban on same-sex marriage.

A federal judge in Mobile ruled in their case last month that Alabama must allow same-sex marriages, striking down its ban and setting the stage for it to become the 37th state, plus the District of Columbia, to permit such unions and the second in the Deep South. The U.S. Supreme Court is scheduled to hear arguments in April over whether there is a constitutional right for gay couples to marry nationwide.

Gay rights supporters likened the actions of Moore and the probate judges to those of Alabama leaders who in the 1960s defied orders to desegregate schools.

“History is repeating itself,” said Christine Hernandez, an attorney for one of the plaintiff couples in the case.

Some social conservatives cheered the actions of the defiant probate judges. Mat Staver, chief executive of Liberty Counsel, said the probate judges are not under the jurisdiction of the federal courts and therefore were not compelled to comply with the federal judge’s order to allow same-sex marriages.

“I think the probate judges acted appropriately,” said Staver, whose group is representing at least eight of the judges.

Their actions show that pockets of deep resistance to gay marriage remain despite the gains made by advocates, who have seen support for their cause spike nationally. Backing for same-sex marriage in Alabama stood at 32 percent in 2012, a smaller proportion than all but two states, according to the Williams Institute, a think tank that studies gay issues.

The conservative profile of Alabama perhaps made it even more notable that scores of couples were able to get licenses Monday.

“It’s about time,” Shanté Wolfe, 21, said with a smile as she left the courthouse in Montgomery with partner Tori Sisson. The couple, who had camped out in a tent to be the first in the county to receive a license, were married Monday.

About 200 couples were able to get them in Huntsville, at least 100 in Jefferson County and large numbers in Montgomery County, said Amanda Snipes, campaign manager for Southerners for the Freedom to Marry.

About 40 percent of the state’s residents live in counties that went forward with the same-sex unions, according to the Southern Poverty Law Center. Couples who ran into difficulties in their own counties were free to marry somewhere else in the state.

“It’s disappointing, but once again, many couples who wanted to get married today are getting married today,” Snipes said. “Although we’re not in a statewide resolution yet, that day will come.”

In Mobile, the decision by Probate Judge Don Davis not to open the marriage-license windows incensed the dozens of gay couples and supporters who had gathered there in hopes of celebrating a milestone moment. For hours, lawyers held backroom meetings with probate judges’ staff members.

The lawyers initially had reassured the crowd that the windows would open. But as hours passed with no communication from Davis’s office, couples who had planned to tie the knot became disheartened.

Kim and Regina Gebauer had come to Mobile rather than try the probate office in their home county of Baldwin, expecting a more welcoming environment, Kim Gebauer said. The two have been together for 22 years and had originally hoped to get a license Monday ahead of a beach wedding later in the month. But as they waited in the lobby of the probate court, the pair had decided instead to get married and “seal the deal” sooner rather than later. In the end, even that plan was thwarted.

“We will celebrate with our friends another time,” said Kim, 51.

Attorneys for the challengers asked Monday that a federal judge find Davis in contempt for not opening the window, but that request was rejected. The lawyers have filed separate legal actions on behalf of at least six couples who were turned away Monday, seeking damages.

At least 12 counties denied licenses to same-sex couples, according to AL.com, an Alabama news site. More than 40 stopped issuing marriage licenses altogether Monday, though at least 20 of those were still accepting applications for marriage licenses. Nine counties agreed to marry everyone.

A letter late Sunday from Moore, the chief justice, advised probate judges to follow state law and refuse to give licenses to gay couples. Those who violated his order would face a reprimand by the governor, Moore wrote.

“Effective immediately, no probate judge of the state of Alabama nor any agent or employee of any Alabama Probate Judge shall issue or recognize a marriage license that is inconsistent” with a constitutional amendment and a state law banning same-sex unions, he wrote.

Alabama Gov. Robert Bentley (R) said Monday that he will not punish probate judges in the state who do or do not issue marriage licenses.

“This issue has created confusion with conflicting direction for Probate Judges in Alabama,” Bentley said in a statement. “Probate judges have a unique responsibility in our state, and I support them. I will not take any action against Probate Judges, which would only serve to further complicate this issue.”

Some legal scholars said the probate judges are unlikely to prevail and faulted Moore.

Moore “may sincerely believe state law takes precedence over federal law,” Ronald Krotoszynski, a professor at the University of Alabama School of Law, said Monday. “And if that’s so, it’s unfortunate because it’s plainly wrong.”

The U.S. Supreme Court rejected Alabama’s request to stay the same-sex marriages until the justices rule later this year on whether there is a constitutional right to gay unions. Two justices, Clarence Thomas and Antonin Scalia, dissented, saying they would have granted the stay.

“I would have shown the people of Alabama the respect they deserve and preserved the status quo while the Court resolves this important constitutional question,” Thomas wrote.

Mark Berman and Brian Murphy in Washington and Robert Barnes in San Francisco contributed to this report.