Sen. Susan Collins of Maine announced Friday that she will not run for governor in 2018, renewing her commitment to serve in a sharply polarized Senate where her centrist Republican positions have made her a key bulwark against much of President Trump's agenda.

Ending months of speculation about her political future, Collins, who does not face reelection until 2020, opted to stick with the job she has held for the last two decades, even as other moderate GOP lawmakers including Rep. Charlie Dent (Pa.) and Sen. Bob Corker (Tenn.) are heading for the exits.

"The best way that I can contribute to these priorities is to remain a member of the United States Senate," Collins told the business crowd, capping a speech in which she described her role as a bipartisan figure on such issues as health care and national security in Washington.

The Maine Republican made her announcement in the coastal Maine town of Rockport, at a Penobscot County Chamber of Commerce breakfast. Her decision was closely held, leaving Republican officials to speculate about her plans in recent days.

Collins read aloud a letter from a Senate colleague: "The institution would suffer in your absence. There are very few who have the ability to bring about positive change; you are such a person." Her final decision, she said, came down to "my sense of where I can do the most for the people of Maine and for the nation."

Collins is seen as the most middle-of-the-road Republican in the Senate, willing to buck Trump and Senate Majority Leader Mitch McConnell (R-Ky.) when she disagrees with them. She opposed two different efforts to dismantle and replace the Affordable Care Act earlier this year, citing the negative impact she believed the plans would have had on vulnerable Americans, particularly in Maine.

Sen. Susan Collins (R-Maine) speaks with reporters on Capitol Hill earlier this month. Collins announced plans Friday that she will remain in the Senate, ending speculation that she would run for Maine governor next year. (Aaron P. Bernstein/Reuters)

In a Senate where Republicans hold a slim 52-48 majority and Democrats are broadly united against much of Trump's agenda, Collins's vote can be pivotal. During the initial health-care push, she was one of three Republicans whose "no" votes ended the effort.

Her announcement Friday served as a reaffirmation of her desire to continue in that instrumental role, at a time when a growing number of Republicans worry about stopping Trump from making controversial decisions with far-reaching consequences.

Republicans are trying for a sweeping rewrite of the nation's tax laws, and many of them hope the overhaul effort will wash away some of the deep anger in the party after the health-care failure. Collins is not viewed as a certain supporter of the tax endeavor.

Collins has come under criticism from Maine Gov. Paul LePage (R) over her position on health care. Such hostility could have complicated her run for governor.

Paul Kane contributed to this report.