Former New York Mayor Rudy Giuliani was running third, and headed for the exits. Officials familiar with events said his aides were in discussions with McCain's advisers on a possible endorsement later in the week.
"It shows one thing. I'm the conservative leader who can unite the party," McCain said in a brief interview with The Associated Press.
"It's a very significant boost but I think we've got a tough week ahead and a lot of states to come."
The victory was worth 57 national convention delegates for McCain, a winner-take-all's haul and the largest single prize to date in the race.
Former Arkansas Gov. Mike Huckabee trailed, but told supporters he would campaign on. Texas Rep. Ron Paul was fifth, and last.
Returns from 64 percent of the state's precincts showed McCain, the Arizona senator, with 36 percent of the vote and Romney, the former governor of Massachusetts, with 31 percent.
McCain's victory was his first-ever primary win in a state that allowed only Republicans to vote. His previous victories, in New Hampshire and South Carolina this year, and in two states in 2000 came in elections open to independents. He campaigned with the support of the state's two top Republican elected officials, Gov. Charlie Crist and Sen. Mel Martinez.
Romney's only primary win so far was in Michigan, a state where he grew up and claimed a home-field advantage. He also has caucus victories to his credit in Wyoming and Nevada.
A survey of voters as they left their polling places showed the economy was the top issue for nearly half the Republican electorate. McCain led his rival among those voters, blunting Romney's weeklong effort to persuade Floridians that his background as a businessman made him best-suited for heading off a recession.
McCain also was benefiting from the support of self-described moderates, as well as older voters and Hispanics. Giuliani ran second among Latino voters, according to preliminary exit poll data.
Romney was favored by voters opposed to abortion and to easing the path to citizenship for illegal immigrants.
About 40 percent of self-described conservatives supported him, as well, compared to about 25 percent for McCain.
The poll was conducted by Edison Media Research and Mitofsky International for The Associated Press and the television networks.
Sen. Hillary Rodham Clinton won the Democratic race, an event that drew no campaigning by any of the contenders -- and awarded no delegates to the winner.
The Democratic primary was controversial by its very existence, an act of defiance against national party officials who wanted it held later in the year.
Even so, Clinton sought to emphasize her performance in the state, holding a rally as the polls were closing.
She challenged Barack Obama to agree to seat the delegates on the basis of the night's vote, but he demurred, saying he would abide by an agreement all Democratic candidates had made months ago.
"Those decisions will be made after the nomination, not before," Obama told reporters Tuesday on a plane from Washington to Kansas. "Obviously, I care a lot about the people in Michigan and a lot about the people in Florida. And I want their votes in the general election. We'll be actively campaigning for them."
Romney began the evening with 59 Republican delegates, to 36 for McCain and 40 for Huckabee. Giuliani had one.
No matter the winner, there was no time to rest. There are 21 GOP contests on the ballot on Feb. 5, with 1,023 delegates at stake.
McCain and Romney clashed early and often, in personal appearances and paid television advertising, in a bruising week of campaigning in Florida.
Romney, the former Massachusetts governor, said his career as a private businessman made him perfectly suited to sit in the Oval Office with a recession looming. Sen. McCain argued he knew his economics well enough, and that his career in the military and in Congress made him the man to steer the country in an age of terrorism.
By the campaign's final hours, the two men hurled insults at one another, each saying the other hoped to travel a liberal road to the presidential nomination in a party of conservatives.
Romney attacked McCain for his signature legislation to reduce the role of money in politics, for his position on immigration and for his support of an energy bill that he said would have driven up consumer costs.
"If you ask people, 'look at the three things Senator McCain has done as a senator,' if you want that kind of a liberal Democrat course as president, then you can vote for him," Romney told campaign workers. "But those three pieces of legislation, those aren't conservative, those aren't Republican, those are not the kind of leadership that we need as we go forward."
McCain had a ready reply. "On every one of the issues he has attacked us on, Mitt Romney was for it before he was against it," he said. "The truth is, Mitt Romney was a liberal governor of Massachusetts who raised taxes, imposed with Ted Kennedy a big government mandate health care plan that is now a quarter of a billion dollars in the red, and managed his state's economy incompetently, leaving Massachusetts with less job growth than 46 other states."
That wasn't all, either.
McCain aired radio commercials criticizing Romney, and his campaign Web site has an ad superimposing Romney's face on the image of a windsurfing Sen. John Kerry, the 2004 Democratic presidential nominee.
The Romney campaign also reported numerous negative phone calls, accusing him incorrectly of supporting taxpayer-funded abortions, opposing President Bush's tax cuts and favoring direct talks with Cuban leader Fidel Castro.
The McCain campaign said it was not responsible for the calls.