Gov. Charlie Baker wrote an op-ed in support of upholding Massachusetts' transgender anti-discrimination law.

Baker, a Republican, published the op-ed Friday in the Rainbow Times, a newspaper for the LGBT community.

Baker wrote that he signed the law "because it was the right thing to do," and he is "troubled" that there is an organized effort to repeal it.

"While I support the ballot initiative process, I strongly believe that the Commonwealth should reject the repeal effort," Baker wrote. "I look forward to voting 'Yes' on Question 3, to uphold the law at the ballot box this fall. I am confident that voters will join me, to re-affirm that the Commonwealth will not tolerate discrimination against our fellow citizens who are transgender."

The law prohibits discrimination against transgender people in public places and allows a transgender person to use the bathroom or locker room that conforms with their gender identity. Voters will decide in November whether to repeal it.

Baker, during his 2014 campaign for governor, initially opposed the law change. He said then that he supported an existing law that protects transgender people from discrimination in employment and housing, but worried about logistical concerns raised by institutions like schools and hospitals about bathroom and locker room use. In 2010, Baker called the bill the "bathroom bill," a term used by its opponents.

But Baker's rhetoric softened over time. He was noncommittal on the law during much of the legislative process and ultimately signed the bill when it reached his desk.

In his op-ed, Baker mentioned his decision to join a court brief supporting universal gay marriage and his addition of LGBT-owned businesses to a diversity program that gives preference in state suppliers and contractors.

Baker earlier this month gave the keynote address at a fundraising dinner for the Log Cabin Republicans, a pro-gay rights Republican group, in Washington. He has a brother who is gay. Baker featured him in campaign ads in 2014.

Baker is facing re-election in November against Democrat Jay Gonzalez.