When Tricia Cotham, a former Democratic lawmaker, was considering another run for the North Carolina House of Representatives, she turned to a powerful party leader for advice. Then, when she jumped into the Democratic primary, she was encouraged by still other formidable allies.

She won the primary in a redrawn district near Charlotte, and then triumphed in the November general election by 18 percentage points, a victory that helped Democrats lock in enough seats to prevent, by a single vote, a Republican supermajority in the state House.

Except what was unusual — and not publicly known at the time — was that the influential people who had privately encouraged Ms. Cotham to run were Republicans, not Democrats. One was Tim Moore, the redoubtable Republican speaker of the state House. Another was John Bell, the Republican majority leader.

“I encouraged her to run because she was a really good member when she served before,” Mr. Bell recalled in an interview.

Three months after Ms. Cotham took office in January, she delivered a mortal shock to Democrats and to abortion rights supporters: She switched parties, and then cast a decisive vote on May 3 to override a veto by the state’s Democratic governor and enact a 12-week limit on most abortions — North Carolina’s most restrictive abortion policy in 50 years.

Overnight, Ms. Cotham became a heroine to Republicans and anti-abortion advocates across the country, even as Democrats vilified her as a traitor whose unexpected party flip had changed health care policy in a politically purple state of more than 10 million people.

More perplexing to many Democrats was why she did it. Ms. Cotham came from a family with strong ties to the Democratic Party, campaigned as a progressive on social issues and had even co-sponsored a bill to codify a version of Roe v. Wade into North Carolina law.

Interviews with former and current political allies depict her as someone who had grown alienated from Democratic Party officials and ideals. Republican leaders cultivated her before she ran and, seeing her growing estrangement, seized a chance to coax her across party lines.

Before the switch, Ms. Cotham chafed at what she perceived as a lack of support from other Democrats. Once she was elected, Mr. Moore said, he made it clear that she would be welcomed by Republicans.

“Never in my life did I think that one person could have that kind of impact, that will affect the lives of thousands of people for years to come,” said Ann Newman, a Democratic activist in Ms. Cotham’s district. Ms. Newman recently asked for — and received — a refund of the $250 she had donated to Ms. Cotham’s 2022 campaign.

Her change of parties has left many of Ms. Cotham’s constituents feeling angry and betrayed, and has allowed Republicans to flex the power of their new supermajority well beyond the abortion issue, overturning a string of vetoes by the state’s Democratic governor, Roy Cooper, including six on June 27 alone.

Ms. Cotham, 44, has defended her switch and said she had delivered on many promises she made to voters.

“I campaigned on Medicaid expansion,” she said in a statement to The New York Times. “I campaigned on supporting children, housing, safer communities, a strong economy and increasing health care options. I’ve done all of this and more.”

Yet there is no question that Ms. Cotham has dealt a grievous blow to Democratic policy goals in North Carolina.

Late in March, just a few days before switching parties, she skipped a pivotal gun-control vote, helping Republicans loosen gun restrictions in the state. After she became a Republican, she sponsored a bill to expand student eligibility for private-school vouchers, voted to ban gender-affirming care for minors and voted to outlaw discussions of race or gender in state job interviews.

“This switch has been absolutely devastating,” said state Representative Pricey Harrison, a Democrat from Greensboro.

Ms. Cotham received a standing ovation at North Carolina’s state Republican convention in June. She was invited to meet privately there with Gov. Ron DeSantis of Florida and former Vice President Mike Pence.

“She’s a rock star among the Republican Party activists and voter base,” said U.S. Representative Dan Bishop, a Republican who said he encouraged Ms. Cotham to join his party and who stood behind her when she announced the decision.

Ms. Cotham had deep Democratic roots when she first entered the state House in 2007, replacing a lawmaker who resigned amid corruption charges. At 28, she became the state’s youngest legislator.

Her mother was active in party politics, and later ran successfully for the Mecklenburg County Commission. A first cousin became a Democratic Party leader in Maine, and ran a political action committee supporting abortion rights.

As a student, Ms. Cotham volunteered for Bill Clinton’s presidential campaign and interned for John Edwards, then a United States Senator.

A lot of people in the Democratic Party “have known her since she was a child,” said Ms. Cotham’s mother, Pat Cotham.

In the North Carolina House, Tricia Cotham was re-elected to four full terms and became a progressive force, calling for higher taxes on the state’s wealthiest residents to help close budget gaps. She criticized charter schools. She fought against the so-called bathroom bill that required people to use restrooms in accordance with their birth gender.

She repeatedly railed against waiting periods for abortions, and speaking on the House floor in 2015, invoked her personal experience.

“Legislators, you do not hold shares in my body,” she said in a speech that has now become famous, “so stop trying to manipulate my mind.”

In 2016, Ms. Cotham chose to run for Congress, rather than for another term in the legislature, and was defeated.

Lacey Williams, a former advocacy director at the Charlotte-based Latin American Coalition who considered Ms. Cotham a friend for years, said Ms. Cotham “felt she did not get the gratitude or spotlight that she felt she deserved,” and added, “she was jealous that other Democrats were getting the adulation from the party.”

In response, Ms. Cotham said Ms. Williams “has a right to her feelings,” but “I do not perceive it that way — I’m a very confident and accomplished woman.”

For a time, Ms. Cotham left elective politics and went into lobbying, with a focus on education. In 2019, she and three partners founded a firm called BCHL. One of the partners was C. Philip Byers, a major donor to state Republicans who was also president of a company that built charter schools.

In office, Ms. Cotham had criticized charter schools, but now her firm supported private investments in the public school system and charter schools. (Ms. Cotham said she had been supportive of public school alternatives “for years.”)

In 2019, she also became president of an education organization called Achievement for All Children, which was chosen by state officials to turn around a foundering public school in Robeson County. For the next year and a half, Ms. Cotham commuted to the school, Southside-Ashpole Elementary, which is about 100 miles from her home outside Charlotte.

Ms. Cotham fought policy battles energetically, recalled Brenda McCallum, an office manager at the school. She also appealed to her younger constituents, once dressing as the Cat in the Hat for a reading event.

“She was an excellent advocate for our school,” said Ms. McCallum. “The kids loved her.”

In early 2020, Ms. Cotham fell sick with Covid-19, a diagnosis that hobbled her for the next two years. In a local television interview in 2022, she said she was still struggling with the virus’s lingering effects.

It was around that time that state Democratic Party officials were homing in on a redrawn state House district in Mecklenburg County, where Ms. Cotham lived, and where Democratic voters outnumber Republicans. Partly because of her public Covid battle, party leaders didn’t seriously consider nominating her, but she surprised them by filing at the deadline in March to run for the seat.

Some Democrats welcomed her return, seeing her as a reliable ally on social issues like abortion, but activist Democrats in the Charlotte area said she never responded to their offers of help. Text messages from political allies and friends, wishing her well, were met with silence.

She fumed that Lillian’s List, an abortion rights organization, had “really screwed” her by endorsing another Democrat in the primary, according to a message she sent to a campaign worker, Autumn Alston, that was reviewed by The New York Times.

Ms. Cotham seemed to have embraced a me-versus-them mentality, said Jonathan Coby, her former campaign consultant. “She would say, ‘Oh, I don’t want to talk to that group, they’re out to get me; they don’t like me,’” Mr. Coby recalled.

Ms. Cotham said that Mr. Coby, who worked with her for nearly a decade, including on her most recent campaign, was not a reliable source of information.

Meanwhile, as Ms. Cotham grew leery of activists and groups on the left, she was receiving counsel from prominent Republicans. “I reached out to her and told her good luck, I hope she wins,” said Mr. Moore, the House speaker. “She was somebody I realized we could work with.”

Ms. Cotham said that Mr. Moore and “others” were pleased that she was running. She called their well wishes “pretty common.”

Both Mr. Moore and John Bell, the Republican majority leader, said they didn’t know at that time that Ms. Cotham would change parties.

Ms. Cotham’s top campaign donors included the North Carolina Dental Society PAC — which gave almost exclusively to Republican candidates — and the North Carolina Health Care Facilities PAC, which gave mainly to Republicans.

“Those groups have honored me with their support for years,” Ms. Cotham said. “I’ve earned it.”

In January, Ms. Cotham was part of a small group of lawmakers who escorted Mr. Moore to the dais to be sworn in as speaker. Some Democrats said they were surprised to see Ms. Cotham play such a role.

In a recent interview, Mr. Moore praised Ms. Cotham’s ability to “work with Republicans at all times.”

Democrats, including Ms. Cotham, sponsored a House bill that month to write Roe v. Wade’s protection of abortion rights into state law. Yet she refused to meet or take phone calls from Planned Parenthood, according to Jillian Reilly, a lobbyist for the group.

Ms. Cotham told Mr. Coby and her mother that she was put off that Democrats treated her as a newcomer when she returned to the House, inviting her to freshman orientation and offering her a mentor. She declined both.

Ms. Cotham would later say she was offended by what she regarded as bullying and groupthink inside the Democratic caucus, which was no longer the “big tent” she had once known. She said the caucus focused too much on process over the hard work of governance.

Democrats said they were baffled by the accusations she later aired. Text messages between Ms. Cotham and house Democratic Party leader Robert Reives reviewed by The Times show friendly dialogue.

“It never would have crossed my mind that she was having issues,” said Mr. Reives.

Mr. Bell, the Republican majority leader, said he was aware of Ms. Cotham’s unease. He and Mr. Moore tried to engage her about joining the G.O.P., telling her “you have a home over here.”

After Ms. Cotham was criticized for missing the vote on gun regulations, Mr. Bishop, the Republican congressman, called her and said he had heard she was thinking of joining his party.

“I got the sense when we talked that she was much farther along in that decision than I had understood before calling her,” he recalled.

After the gun vote, Mr. Coby said he found Ms. Cotham to be angry. “She said, ‘I’m either going to switch parties or resign,’” he remembered. “The things she was telling me then were like, ‘The Democrats don’t like me, the Republicans have helped me out a lot and been nice to me’.”

Four days later Ms. Cotham announced her decision to defect. “The party wants to villainize anyone who has free thought,” she said of the Democrats during a news conference.

She accused Democrats of spreading “vicious rumors” about her — perhaps alluding to chatter that she and Mr. Moore were romantically linked. Mr. Moore has denied the assertion; Ms. Cotham called it “insulting.”

Ms. Cotham was soon fielding thousands of texts, emails and phone messages calling her a traitor and liar, delivering vulgarities her mother described “as a new low in society” and demanding that she resign.

Four months after Ms. Cotham’s party switch, the bitterness still runs deep.

Linda Meigs, a political activist from Charlotte, drove to Ms. Cotham’s district this month for a meeting with local lawmakers hosted by Common Cause North Carolina and other liberal advocacy groups.

Ms. Meigs said she had come prepared to confront Ms. Cotham over how she could have campaigned on “Democratic Party values such as women’s rights to reproductive freedom and L.G.B.T.Q. rights,” only to reverse her support. Ms. Cotham was invited to speak, but didn’t attend.

“When I’m talking to somebody and asking them a question, I usually like to look them in the face,” Ms. Meigs told a crowded room at a Mint Hill church. “I can’t do that tonight.”

Instead, she pointed to a front-row chair. “So,” she said to cheers, “I’m going to talk to this empty chair.”

Bryan Anderson contributed reporting from Raleigh, N.C. Kitty Bennett contributed research.