Gov. Charlie Baker said Tuesday he would sign a House version of a bill that would ban discrimination against transgender people.

Baker said he'd support the bill as written because it protects against sexual predators taking advantage of the law by entering restrooms and locker rooms for nefarious reasons, such harassing women or children.

“No one should be discriminated against in Massachusetts because of their gender identity," Baker said in a statement released Tuesday afternoon.

"After hearing from all sides and carefully reviewing the two separate proposals that have been working their way through the Legislature, I believe the House version addresses the concerns that some have with the bill by requiring the attorney general to issue regulations to protect against people abusing the law. I would sign the House version in its current form should it reach my desk.”

The bill would ban discrimination against transgender people in public spaces, and would allow transgender individuals to use the public restroom or locker room that matches their gender identity. The House is expected to debate the bill on Wednesday.

The State House News Service contributed to this report.