(CNN) Former Rep. Beto O'Rourke of Texas said on Thursday that conversion therapy "should be illegal" and compared the widely discredited practice that seeks to change the sexual orientation of gays, lesbians and bisexuals to torture.

"As president, we will seek to outlaw it everywhere in this country," the Democratic candidate said Thursday at an LGBTQ town hall hosted by CNN and the Human Rights Campaign Foundation. "In my opinion, this is tantamount to torture. Torture that we're visiting on children who are absolutely defenseless."

So-called conversion therapies, sometimes referred to as reparative treatments, center on the debunked assumption that sexual orientation can be changed by a series of procedures. The practice is widely decried, and a number of states have made it illegal.

"We're going to make sure that whatever the penalty is, it is steep enough to dissuade anybody from entering into this practice or being able to torture kids with the kind of impunity that we have seen so far," O'Rourke said.

The former congressman continued: "We're also going to recognize that these kind of practices, in addition to the immediate torture that that child or that person feels, also adds to other challenges that we have." He connected conversion therapy with homeless youth in America.

Read More