HELENA, Mont. — As Montana lawmakers entered the critical final days of their legislative session on Thursday, one of the state’s only transgender lawmakers, Zooey Zephyr, was left exiled from the House chamber, monitoring the debate and casting votes on a laptop as she sat on a hallway bench near a bustling snack stand.

Even as her Republican peers sought to isolate her in the wake of her impassioned comments against a proposed ban on what doctors call gender-affirming medical care for children, Ms. Zephyr said she would not remain idle. She spent much of the day on the bench, working with headphones in her ears to block the sound of chattering lobbyists, the hiss of a milk foamer and the voices of lawmakers ordering coffee.

“I am here working on behalf of my constituents as best I can given the undemocratic circumstances,” Ms. Zephyr said on Twitter.

In a state that has long prided itself on independent thinking, the free exchange of opinions and limited government, the decision to bar Ms. Zephyr from the House floor has become a stark illustration of how a state that had a Democratic governor as recently as 2020 has ushered in a new Republican supermajority whose leadership appears bent on flexing its muscles.

“I have loved this purple state that I’ve grown up in,” said Mallerie Stromswold, a former Republican lawmaker who left the Legislature earlier this year after she clashed with party leaders over a series of proposed transgender bills and closed-door meetings, she said, devolved into yelling and name-calling.

For decades, Montana voters had demonstrated an independent streak, often hopping between parties when casting their ballots. In 2004, the state voted for George W. Bush, a Republican, for president by more than 20 percentage points while also selecting a Democrat, Brian Schweitzer, to become governor.

But in recent years, as the state has experienced an influx of conservative transplants and joined an increasingly polarized national political debate, Republicans have steadily expanded their control, especially in rural Montana, which had often been the scene of vigorous and competitive political contests.

“We’ve lost our rural base,” said Bill Lombardi, a former aide to U.S. Senator Jon Tester, the lone Democrat still holding statewide office in Montana. Mr. Tester is running for re-election in 2024.

Cyndi Baker, the chair of the Cascade County Republican Party, around Great Falls, said Montana voters had embraced the G.O.P. as the Democratic Party shifted to the left, a move that she said left moderate candidates stranded.

In her county, she said, Republicans once considered it a victory to hold half of the area’s legislative seats. Now, every seat is held by a Republican; the county sheriff switched his affiliation from Democrat to Republican.

“To tell you the truth, it shocked even me, the scope of our wins,” Ms. Baker said.

Last year, Republicans gained a supermajority in both houses of the Legislature, positioning Montana as a new front in the nation’s culture wars.

Missoula, the Western-chic college town that Ms. Zephyr represents, has become an encircled island of progressive politics, nurtured by a robust environmental movement and the intellectual ferment at the University of Montana. The city offers whitewater rafting through the surrounding Rattlesnake Mountains and craft breweries across a downtown that features a rainbow crosswalk to celebrate the city’s embrace of L.G.B.T.Q. rights.

Ms. Zephyr was elected to the Legislature last year, campaigning on a platform that included advocating for the rights of marginalized people. She won with about 80 percent of the vote.

Her entry into politics coincided with Republican moves to push a series of bills on transgender issues, similar to moves in a growing number of other states.

Earlier this month, as some of those bills moved toward passage in the state capital of Helena, Ms. Zephyr stood on the House floor to tell colleagues that passing a bill to prohibit hormone treatments and surgical care for transgender minors would be “tantamount to torture” and would result in “blood on your hands” for lawmakers who approved it.

The House’s Republican leadership initially responded to the blunt remarks by refusing to recognize Ms. Zephyr in floor discussions. Members of the conservative Montana Freedom Caucus accused Ms. Zephyr of “standing in the middle of the floor encouraging an insurrection” when her supporters, who were protesting noisily from the gallery, were ordered to disperse.

Then on Wednesday, citing violations of decorum, Republicans voted to bar her from the chamber for the rest of the session, which was scheduled to end next week.

The ejection vote on Wednesday sparked anger and confusion in Missoula, where a network of Ms. Zephyr’s supporters began exchanging messages, trying to decide how to respond. A 24-hour protest event that would include a rally, a street party and drag shows was planned for Friday evening.

Izzy Milch, 25, who has long lived in Ms. Zephyr’s district and campaigned for her election, said Ms. Zephyr had an impressive command of policy and an ability to connect with her constituents. Mx. Milch, who uses they/them pronouns, said the legislative punishment was anti-democratic and antithetical to the state’s history.

“What I love about Montana is we look out for our neighbors and take care of each other,” they said. “Beyond that, we don’t care about people’s private lives.”

Dan Hall, 62, a former Republican and current registered Democrat who has lived in the district for 40 years, said that even before Ms. Zephyr was barred from the House floor, the State Legislature seemed different this year under the new Republican supermajority.

“They want to tell people what their identity is,” he said. “They want to tell people who they can marry. They want to tell people where they can work. They’re reaching into all these private areas of people’s lives. And this is wrong. This is not who we are.”

Republican leaders have said that the issue with Ms. Zephyr is not about freedom of speech, but rather the chaos that erupted when her supporters spoke out loudly in the House chambers, chanting, “Let her speak” as Ms. Zephyr held a microphone over her head to capture the cacophony. Police officers eventually cleared the room.

Steve Daines, Montana’s Republican U.S. Senator, commended the Republican House leadership and law enforcement officers for their response.

“Spirited debate is encouraged in our democracy — it’s part of what makes our country great but with that comes a responsibility to be civil and to avoid extreme rhetoric and violence,” he said on Twitter. “Endangering lawmakers and their staff is unacceptable.”