President Barack Obama on Sunday blasted the Republican Party and GOP candidates running in the 2016 presidential race for their opposition to same-sex marriage in spite of the growing percentage of Americans who favor marriage equality.

Without naming names, Obama called out prominent 2016 hopefuls in the Republican Party for being on the wrong side of history, during a speech at a Democratic National Committee fundraiser in New York.

"The good news is they probably won't use marriage equality as a wedge issue like they did in 2004 because the country has come too far. In fact, America has left the leaders of the Republican Party behind," the president said, according to The Huffington Post.

Obama also dismissed Republicans for ‎living in the past, and for using religious liberty as a justification to deny and attack LGBT rights.

"We affirm that we cherish our religious freedom and are profoundly respectful of religious traditions. But we also have to say clearly that our religious freedom doesn't grant us the freedom to deny our fellow Americans their constitutional rights," he said at the Democratic Party fundraiser, which was held at Gotham Hall.

Obama went on to lambaste anti-LGBT statements made by GOP candidates, which he described as out-of-touch with reality.

"One of their leading candidates argued that going to prison turns you gay," Obama said, referring to 2016 hopeful Ben Carson, who had claimed earlier this year people in prison chose to be gay.

Obama continued, noting, "Another candidate boasts that he introduced an amendment to end nationwide marriage equality -- which isn't even an accomplishment at all. A third says Americans should just disobey the Supreme Court's ruling entirely. I'm sure he loves the Constitution -- except for Article III. And maybe the Equal Protection Amendment. And the 14th Amendment, generally," Obama said, referring to Texas Sen. Ted Cruz and former Arkansas Gov. Mike Huckabee.

"We need to reject politicians who are supporting new forms of discrimination as a way to scare up votes," he added. "That's not how we move America forward."

Obama also claimed Republican presidential contenders are off base in their criticism of how he rejuvenated the nation following the 2008 financial meltdown.

"In their world, everything was terrific back in 2008 when we were in the midst of a spiral into the worst financial crisis and economic crisis since the Great Depression, when unemployment and uninsured rates were rising and when our economy was shedding jobs each month, and we were mired in two wars, hopelessly addicted to foreign oil, and bin Laden was still at large," he said, reports CNN.

"Those were the Golden Years, apparently. And then, I came in and messed it all up."

At another point in the speech, Obama touted his record on supporting the LGBT community and passing pro-LGBT legislation, including his repeal of Don't Ask Don't Tell, his executive order banning workplace discrimination against federal workers who happen to be queer, and the Supreme Court ruling that legalized gay marriage.