AUGUSTA — Gov. Janet Mills signed a bill Wednesday making Maine the 17th state to ban so-called “conversion therapy” that attempts to change the sexual orientation or gender identity of minors.

Mills, a Democrat, signed the bill while surrounded by legislators, young people and advocates for Maine’s LGBTQ community who were involved in the multiyear effort to enact a ban on conversion therapy.

The bill, which was sponsored by Assistant Majority Leader Rep. Ryan Fecteau, D-Biddeford, would prohibit state-licensed counselors, psychologists, social workers, health professionals, guidance counselors, and pastoral and family therapists from engaging in conversion therapy.

The new law defines conversion therapy as “any practice or treatment that seeks or claims to change an individual’s sexual orientation or gender identity, including, but not limited to, any effort to change gender expression or to eliminate or reduce sexual or romantic attractions, feelings or behavior toward others based on the individual’s gender.”

It would not prohibit treatment for individuals undergoing gender transition, counseling that seeks to prevent unsafe sexual practices or any “neutral” talk therapy intended to help a minor cope with issues.

A similar bill passed the Legislature last year only to be vetoed by former Republican Gov. Paul LePage.

“Conversion therapy is a harmful, widely discredited practice that has no place in Maine,” Mills said in a statement. “By signing this bill into law today, we send an unequivocal message to young LGBTQ people in Maine and across the country: We stand with you, we support you, and we will always defend your right to be who you are.”

The practice is now banned in every New England state plus 11 other states and the District of Columbia.