Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

ROCKPORT, Maine — Ending months of speculation, Sen. Susan Collins, R-Maine, announced Friday she will forgo a run for governor to stay in the Senate, where she has become a crucial swing vote in Republicans’ narrow two-seat majority.

“I want to continue to play a key role in advancing policies,” Collins said at a Chamber of Commerce breakfast at a golf resort here. “I have concluded that the best way that I can contribute to these priorities is to remain a member of the United States Senate."

Collins, one of the few remaining moderate Republicans in Washington, has long been viewed as an independent voice and a check on her party’s right flank, including President Donald Trump.

U.S. Senator Susan Collins departs after the weekly Republican caucus policy luncheon at the U.S. Capitol in Washington, U.S. Sept. 19, 2017. Jonathan Ernst / Reuters file

She provided one of the three GOP votes to kill her party’s Affordable Care Act repeal effort, which she criticized Friday.

Collins said she is "very concerned" with Trump's new executive order on healthcare and his decision to end a key ACA subsidy, both of which could undermine the law, experts say.

She chided her party for bypassing the normal legislative process to draft their health care plan behind closed doors — “by the way, it was 13 men who did it,” said the pro-choice Republican. Collins also called the last-ditch Graham-Cassidy repeal bill “a very bad bill for the state of Maine."

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

“Republican leaders made the same mistake Democrats made in passing the ACA without a single Republican vote,” Collins said.

Collins’ departure would have dramatically reshaped the Senate, and Washington more generally, while also upending Maine’s 2018 gubernatorial race.

Related: Sen. Collins Has ‘Serious Reservations’ Over GOP’s Obamacare Repeal

She’s proud of having never missed a vote in her 20 years in the Senate, and said her seniority in the chamber was too important to give up.

Collins had been agonizing over the decision for months, but now joins a long list of senators who have made high-profile gubernatorial considerations, only to swerve at the last minute.

The senator will serve out the remainder of her term, which ends in 2020, but made no announcement about whether she will run for reelection.

Both of Collins’ parents served as mayors of her hometown, and she is a proud heir to the long tradition of moderate New England Republicanism.

But both in Maine and nationally, the party has shifted away from Collins. There is no love lost between her and Trump, nor her and Maine’s bomb-throwing GOP governor, Paul LePage.

“She has a strong commitment to the Republican Party not being the party of Trump and LePage,” said Amy Fried, the chair of the political science department at the University of Maine.

Many political observers think that Collins, despite her popularity in Maine, would have had a hard time winning a GOP primary. The party’s current frontrunner is an ally of LePage, who is term-limited and cannot run again.

“I do firmly believe deep down in my heart that Susan Collins, in order to become governor of the state of Maine, will have to run as an independent,” LePage told Portland radio station WGAN in August, adding that she would be “highly unlikely to win a Republican primary.”

Collins told reporters Friday she was confident in her ability to win as a Republican and that she never seriously considered running for governor as an independent. She made her final decision Wednesday, Collins added.

“I’m often a bridge between the two sides," she said. "So I like playing that role, and there seemed to be fewer and fewer senators who enjoy playing that role.”