State lawmakers in Montana on Tuesday rejected a proposal that could have restricted bathroom access for transgender lawmakers at the State Capitol in Helena.

The decision came down to a narrow vote in the Legislature’s joint rules committee. All Democrats opposed the measure. Several Republicans argued against it, too.

“This particular action will have the effect of making people famous in the national news,” Representative David Bedey, a Republican from Hamilton, said during the committee meeting, “and will not contribute to the effective conduct of our business.”

The proposal, which addressed the restrooms reserved for lawmakers between the House and Senate chambers, would have effectively barred transgender people from using the bathrooms that align with their gender identities.

Representative Jerry Schillinger, a Republican from Circle who sponsored the measure, said it would ensure that “the gals’ restroom will be used only by gals, and the guys’ restroom will be used only by guys.”

The debate over the measure came about a month after the re-election of Zooey Zephyr, a Democrat from Missoula and a transgender woman who is now beginning her second term in the State House.

“I’m happy to see that this proposed ban failed and am grateful for my colleagues, particularly my Republican colleagues, who recognized this as a distraction from the work we were elected to do,” Ms. Zephyr said in a statement on Tuesday.

In an email, Ms. Zephyr said that she would be focused on housing and health care during the upcoming session.

Ms. Zephyr faced restrictions during her first term. In April 2023, she was barred from participating in deliberations in the House chamber after she made impassioned arguments against a bill to ban hormone treatments and surgical care for transgender minors.

The bill passed and was signed by Gov. Greg Gianforte, a Republican, though it has since been held up by challenges in court.

The State Legislature is dominated by Republicans. In the joint rules meeting on Tuesday, several of them questioned the wisdom of enacting a new restroom rule.

Edward Buttrey, a Republican representative, voted for the measure but raised questions about whether it would force legislators “to take some type of test” to determine their gender. “I get what the sponsor’s trying to do,” he added. “I’m just not sure how this would be put into effect and be utilized.”

Jedediah Hinkle, a Republican from Belgrade who also supported the proposed rule, said that during Montana’s last legislative session — Ms. Zephyr’s first — some women in the chamber had opted to avoid the nearby bathroom and walk to a farther one instead. (During the committee discussion before the vote, no women spoke for or against the rule.)

“I think it’s time that this body addresses this issue now, as they are addressing it nationally,” Mr. Hinkle said. “We need to set that precedent right now that women have their spaces, and they need to be comfortable in those spaces.”

Over the last two years, Republicans in state legislatures and in Washington, D.C., have proposed legislation that would roll back the rights of transgender people or require people in government buildings to use bathrooms associated with their sex assigned at birth.

Last month, U.S. Representative Nancy Mace of South Carolina announced plans to introduce a measure to bar transgender women from using women’s restrooms and changing rooms in the U.S. Capitol complex. That came shortly after Sarah McBride, a Delaware Democrat, became the first openly transgender person elected to Congress.