(Jabin Botsford/The Washington Post)

A debate over a North Carolina law that rolled back protections for gay and transgender people roiled the Republican presidential race Thursday, with front-runner Donald Trump criticizing the measure as bad for business and Ted Cruz defending it as something that will protect young girls.

The North Carolina law has been dubbed the "bathroom bill" and now "bathroom law" because it mandates that people use the restroom that corresponds to the sex on their birth certificate. It sparked a major backlash from LGBT groups and businesses, including PayPal and Deutsche Bank, which both scrapped plans to create jobs in the state. The British Foreign Office issued an advisory Tuesday warning citizens about traveling to North Carolina and Mississippi, where a law enacted last month allows businesses to refuse service to same-sex couples on religious grounds.

Trump said there was little controversy before the law was passed, and the measure has done nothing but hurt North Carolina economically. Businesses including American Airlines, Facebook and Google have condemned the measure, and the National Basketball Association hinted it might relocate next year's all-star game from Charlotte.

“You leave it the way it is. There have been very few complaints the way it is. People go, they use the bathroom that they feel is appropriate. There has been so little trouble,” Trump said on NBC’s “Today” show Thursday. “And the problem with what happened in North Carolina is the strife and the economic. … I mean, the economic punishment they’re taking."

Trump's comments were met with fierce opposition from Cruz, who defended the law last week.

"Donald Trump is no different from politically correct leftist elites. Today, he joined them in calling for grown men to be allowed to use little girls’ public restrooms. As the dad of young daughters, I dread what this will mean for our daughters — and for our sisters and our wives. It is a reckless policy that will endanger our loved ones," Cruz said in a statement Thursday.

The debate over the bill comes as the presidential race moves into the more socially liberal northeast, where five states were voting Tuesday. Both men are now positioning themselves for a general election, most likely against Hillary Clinton, who has been a champion of gay rights. Clinton and her rival for the nomination, Sen. Bernie Sanders (Vt.), have spoken out against the law.

Trump has swung in numerous directions on social issues, making controversial comments about women and abortion, but also praising Planned Parenthood for the work it does. Cruz has attempted to be the most socially conservative candidate in the race, calling the Supreme Court's decision legalizing same-sex marriage "illegitimate" and spearheading a nationwide effort to defund Planned Parenthood.

Cruz has used social issues as a wedge against Trump, citing the businessman's past comments supporting abortion rights and being nonplussed about same-sex marriage. He has now seized on Trump's support for the North Carolina bill, which Gov. Pat McCrory backpedaled from earlier this month, signing an executive order extending some protection to LGBT state employees.

"Donald stands up for this irresponsible policy while at the same time caving in on defending individual freedoms and religious liberty. He has succumbed to the Left's agenda, which is to force Americans to leave God out of public life while paying lip service to false tolerance," Cruz said in a statement. The candidate said Britain's travel advisory and genderless bathrooms are "absurd."

The Texas Republican discussed the bill on Glenn Beck's radio show Thursday morning. Beck, a Cruz supporter who holds rallies for the candidate around the country, said he is concerned not about transgender people but the "heterosexual pervert" who could use a bathroom with his daughter or wife.

"The idea that grown men would be allowed alone in a bathroom with little girls … you don’t need to be a behavioral psychologist to realize bad things can happen, and any prudent person wouldn’t allow that," Cruz said.

Beck compared his stance to what he said is a liberal argument on gun control.

"I will tell you that we always hear from the left on gun control … if it would just save one person then we should do it. If this would just save one little girl from being molested by a heterosexual pervert, we should do it," Beck said.

Cruz spoke about his time as solicitor general of Texas, where he said he handled numerous cases involving pedophiles and child molesters.

"There are some bad people in the world, and we shouldn’t be facilitating putting little girls alone in a bathroom with grown adult men. That is just a bad, bad, bad idea," Cruz said.

Jose A. DelReal contributed to this post.