NEW YORK — In the two years since same-sex marriage was legalized nationwide, support for it has surged even among groups that recently were broadly opposed, according to a new national survey.

The Pew Research Center survey found that for the first time, a majority of blacks and baby boomers support allowing gays and lesbians to wed. It said Republicans are now split almost evenly, a marked shift from 2013, when 61 percent opposed gay marriage.

Pew’s survey was conducted by telephone among 2,504 adults across the U.S. from June 8 to 18. It was released Monday, the second anniversary of the Supreme Court’s historic ruling.

In the aftermath of that ruling, there were some flare-ups of defiance. A county clerk in Kentucky, Kim Davis, refused to issue marriage licenses to same-sex couples. Alabama’s chief justice, Roy Moore, ordered probate judges to stop issuing such licenses.

But such acts of resistance have largely faded way, and same-sex marriage is now treated as a routine occurrence across the U.S. According to the Williams Institute at UCLA School of Law, there are now more than 547,000 same-sex married couples in the U.S., including at least 157,000 couples married in the past two years.

Some staunch opponents of gay marriage are now focusing their efforts on trying to provide legal protections to civil servants, merchants and other business people who do not want to provide services to same-sex couples. Mississippi, for example, has passed a law – now the subject of litigation in federal court – that would let businesses and government workers deny some services to gay and lesbian couples.

There’s a case now pending before the Supreme Court involving a Colorado baker who was found guilty of discrimination for refusing to sell a gay couple a wedding cake. A florist in Washington state also is expected to appeal to the high court after she was fined for violating that state’s anti-discrimination law because she would not provide flowers for a same-sex wedding.

Some of the notable findings in the Pew survey:

• Overall, 62 percent of Americans now support same-sex marriage, the highest level in 20 years of Pew polling on the issue. As recently as 2010, support was at 42 percent.

• Among baby boomers, support is now at 56 percent – up from 46 percent a year ago.

• Support among blacks has risen from 39 percent to 51 percent over two years.