Senator Marco Rubio of Florida said Wednesday that he has decided to seek re-election to the Senate after months of insisting he would not run again, a reversal that will reshape one of the most competitive races in the country.

Mr. Rubio, 45, who is said to be reluctant to give up the high profile that a Senate seat offers, will enter the race with the formidable advantages of incumbency, national name recognition and strong ties to the Republican Party’s donor base.

But he also faces numerous hurdles. He is coming off a bruising race for president that ended with an embarrassing loss to Donald J. Trump in his home state on March 15 — one that focused in no small part on his frequent absence from the Senate and from his duties in Florida as he campaigned.

He also made no secret of his distaste for Washington and the often glacial pace of business on Capitol Hill, words he is certain to see turned against him in attack ads from Democrats who had been optimistic about their chances at taking back Mr. Rubio’s seat before he entered the race.

In an interview with Fox News on Wednesday, Mr. Rubio acknowledged his about-face and tried to explain himself in part by saying, “I changed my mind.”

“I think it’s clearly outlined that I’m frustrated by what’s happening here in the Senate — most Americans are,” he added.

Then, in a dig at the presumptive nominees of both political parties, Mr. Rubio said he ultimately believed that no matter who is elected president, the Senate has the vital role “of being able to act as a check and balance on bad ideas from the president.”

The senator has told colleagues and advisers that he would like to run for president again, either in 2020 or 2024. But he increasingly came to think that doing so from the private sector would be difficult.

His decision is not without considerable risk to his political future, despite his status as a nationally known incumbent who will have the full backing of the National Republican Senatorial Committee.

According to people who have spoken with Mr. Rubio in recent days, the senator is especially concerned about the effect that Mr. Trump’s candidacy could have on his chances of winning. A poor performance in the November general election by Mr. Trump against Hillary Clinton in Florida, with its large Hispanic population, could hurt Mr. Rubio.

Mr. Rubio’s move was truly last-minute. Florida’s deadline to file as a candidate is Friday.