The Massachusetts Senate has approved a bill aimed at banning discrimination against transgender people in public accommodations such as restaurants, malls and other locations.

The bill also would let transgender people use bathrooms that correspond with their gender identity. It expands a 2011 state law that already bans discrimination against transgender people in the workplace and housing.

The Senate passed the bill on a 33-4 vote Thursday, with four Republican lawmakers opposed.

Democratic Sen. Sonia Chang-Diaz said it's past time for Massachusetts to approve the bill. Seventeen states and the District of Columbia have similar laws.

"In Massachusetts we are civil rights pioneers by nature, it is in our cultural DNA," Chang-Diaz said. "That's why it's particularly difficult to fathom how it is in 2016 we are still fighting for public accommodations and full equality for transgender Bay Staters."

Opponents said the bill would violate the privacy rights of women and girls in bathrooms and locker rooms.

Republican Gov. Charlie Baker hasn't said whether he would sign the bill but indicated a preference for the House version, which includes language intended to discourage and punish false gender identity claims.

Democratic Senate President Stan Rosenberg praised Thursday's vote.

"As a member of the LGBT community it's really big for me," said Rosenberg, who is gay. "This is a fundamental right."

Transgender activists thanked lawmakers.

"My heart breaks with gratitude. I can't thank you enough," Lorelei Erisis, a transgender woman from Ayer, said after the vote. "I'm a writer and I'm losing words. Thank you so much for standing with us and for protecting us."

Critics argue that male sexual predators could claim to identify as female to gain access to women's restrooms or locker rooms.

Massachusetts Family Institute President Andrew Beckwith says women and children will have no protection against being exposed to men in locker rooms if the bill is passed.

"If this legislation is passed, woman and children will have no protections against being ogled by, or exposed to, naked men," Beckwith said.

Supporters of expanded protections for transgender people say such fears are unfounded and haven't been a problem in states that have passed public accommodations laws.

Rosenberg dismissed the criticism, saying that transgender men are men and transgender women are women. He called the House provision redundant since Massachusetts already has laws targeting sexual predators.

During the debate, senators rejected an amendment that would have created an exemption for gender-based locker rooms and showers where there is an expectation of privacy.

Elizabeth Fournier also opposes the bill. The 18-year-old Seekonk resident said that while the bill tries to reduce the discomfort that transgender individuals might feel by being in a particular bathroom, it merely shifts the discomfort to others.

"In many cases those who will suffer the most from this redistribution of discomfort are women and children," Fournier said. "Nothing is gained by the passing of this bill except to favor one group over another based on entirely subjective criteria."

The Senate bill includes an emergency preamble, meaning that it would take effect immediately after being signed.

The debate now heads to the House.