Republican Sen. Marco Rubio won a second term Tuesday by defeating Democratic congressman Patrick Murphy, capping a pivotal year in which the Floridian went from an establishment favorite for president to a late entrant into the race for his own Senate seat.

Networks and the Associated Press called it for Mr. Rubio moments after the final polls closed, increasing the GOP’s chances of preserving their 54-46 majority as results trickled in.

Mr. Rubio, who rode into the Senate as part of the 2010 tea party wave, hadn’t planned to seek reelection, but he shifted course after he became one of Donald Trump’s many victims in the GOP presidential primary.

The 45-year-old cited the mass shooting at a gay nightclub in Orlando on June 12 in his reassessment, saying “it really gives you pause to think a little bit about, you know, your service to your country and where you can be most useful to your country,”

Mr. Rubio led in the polls throughout the campaign, nicknaming his opponent “privileged Patrick” for using campaign cash from his father, while pointing to news reports that said Mr. Murphy inflated his resume.

Yet Mr. Murphy and leading Democratic surrogates, including President Obama, questioned Mr. Rubio’s commitment to the Senate, particularly since the GOP senator missed many votes during the campaign and lamented how ineffectual the Senate can be with the wrong person in the White House.

Mr. Murphy also doubted whether Mr. Rubio would serve his full, six-year term, since the Republican has declined to rule out a presidential bid in 2020.