The City Council on Thursday voted to outlaw so-called conversion therapy — the discredited practice of trying to reverse a patient’s homosexual urges or to adopt the gender identity on the patient’s birth certificate.

Under the legislation, which awaits the mayor’s signature or veto, offering or providing the therapy would be punishable by civil fines up to $1,000 for the first violation, $5,000 for the second violation, and $10,000 for each violation afterward.

“Conversion therapy is a form of psychological torture — plain and simple,” said Councilman Danny Dromm (D-Queens), who is gay and one of the bill’s prime sponsors. “As ridiculous as it seems, the practice still persists, even in New York.”

The bill passed 43-2, with 1 abstention.

“We will ensure all individuals will be able to live without fear of coercion to change into someone they are not,” said another prime sponsor, Melissa Mark-Viverito (D-Manhattan), the council speaker.

Conversion therapy, opposed by the American Psychiatric Association, goes by different names — sometimes “sexual reorientation” or “reparative therapy.” It’s often based on the Freudian notion that sexual attraction exists on a continuum spanning opposite sex and same-sex attraction.

Some therapists counsel patients on stopping the unwanted thoughts, and others focus on religious or spiritual counseling. Therapy sometimes has involved shocking patients with electricity or inducing nausea with drugs while viewing same-sex photos.

Asked whether Mayor Bill de Blasio would sign the legislation, Introduction 1650, his spokeswoman Olivia Lapeyrolerie said, “Conversion therapy is barbaric, and we are currently reviewing the bill.”

Councilmen David Greenfield of Brooklyn, who voted against the bill, and Andy King, who abstained, said after the council meeting that religious concerns influenced their decisions.

Greenfield, who represents several Orthodox Jewish communities, said he worried about how potential constitutionally protected religious choices could be infringed upon by the legislation in his district.

“Within segments of some of the communities that I represent, there are folks who are having this conversation, and it’s not clear to me what kind of impact it will have on those folks,” Greenfield said. “I think we should be respectful, specifically, of people who are making personal religious choices.”

“I’m not going to violate my religious beliefs because of a job, because once the job is gone, I still have my beliefs,”King said, explaining, “I follow the Jewish faith.”

The council’s other “no” vote, Chaim Deutsch of Brooklyn, told a reporter in the City Hall parking lot that he would explain his vote by email but hadn’t responded as of early evening.

Conversion therapy is now banned in some form in at least nine states, including Nevada, New Jersey and Connecticut. Last year, New York State restricted the practice via Gov. Andrew M. Cuomo’s executive order by cutting off insurance payments for treatment and banning the practice for minors.

The legislation being voted on by the council bans the practice citywide for patients of any age.