Mr Giuliani pledged to campaign with Mr McCain when needed |
Mr Giuliani announced he was giving his support to Arizona Senator John McCain, describing him as "an American hero".
Arnold Schwarzenegger, California Governor, will later endorse Mr McCain.
Earlier, Democrat John Edwards left the race, without backing any of his rivals, after failing to win a single party nomination contest.
Mr Edwards contested Iowa, New Hampshire, Nevada and his native South Carolina, but only in Iowa did he get higher than third place, and that only by the narrowest of margins.
He told supporters in New Orleans, where he launched his latest White House bid in 2006: "It's time for me to step aside so that history can blaze its path."
His endorsement could be crucial in the tight race between the two remaining Democratic candidates, Hillary Clinton and Barack Obama.
Heated debate
Mr Giuliani announced his withdrawal just before the remaining Republican candidates began a televised debate at the Reagan Library in Simi Valley, California, on Wednesday.
With the two other candidates - former Arkansas Governor Mike Huckabee and Texas Congressman Ron Paul - often struggling to be heard, the 90-minute debate was dominated by the verbal jousting of the two front-runners.
The Republican debate saw tense exchanges between candidates |
Former Massachusetts Governor Mitt Romney accused Mr McCain of "dirty tricks" for accusing him - just before Tuesday's Florida primary - of supporting a date for withdrawing troops from Iraq.
"It's offensive to me that someone would suggest that I have," said Mr Romney.
Mr Romney said Mr McCain was out of the conservative mainstream, having twice voted against President George W Bush's tax cuts, which the Republican establishment had embraced.
Mr McCain countered that he was proud of his conservative credentials, and questioned Mr Romney's administrative record in Massachusetts.
"His job creation was the third worst in the country," said the Arizona senator.
The simmering tensions were indicative of the pressure that is building ahead of next week's "Super Tuesday", when 24 states hold their nominating votes in what could be a decisive day in the race to succeed Mr Bush.
Rudy's gamble
In contrast to the heated exchanges in Simi Valley, Mr Giuliani's address was light-hearted.
He said he had thought he was the sort of person who had the qualities to make a good president of the United States, "but the voters made a different choice".
"John McCain is the most qualified candidate to be the next commander in chief of the United States," Mr Giuliani said. "He's an American hero and America could use heroes in the White House."
FLORIDA PRIMARY: RESULTS Republicans John McCain: 36% Mitt Romney: 31% Rudy Giuliani: 15% Mike Huckabee: 13% Ron Paul: 3% Democrats Hillary Clinton: 50% Barack Obama: 33% John Edwards: 14% With 99% of vote counted |
He added that Mr McCain was a long-standing friend and that he would campaign alongside him whenever and wherever he was needed.
Mr McCain returned the compliments, praising Mr Giuliani's leadership as mayor in the wake of the attacks on the US on 11 September 2001.
He described his former rival as "my strong right arm and my partner".
"This man is a national hero and I'm honoured by his friendship," he said.
Mr Giuliani was seen by his supporters as a tough commander-in-chief, while other Republicans were wary of his attitude on social issues like abortion.
When he entered the race more than a year ago, he led some national polls and had an impressive war chest. He is reported to have spent up to a million dollars a week on TV advertising in Florida alone.
Correspondents say his decision to focus his efforts on Florida was always going to be either a stroke of political genius or an unwise gamble that would see him fall at the first hurdle.
Mr Giuliani won 15% of the vote, behind Mr McCain with 36% and Mitt Romney with 31%, and just ahead of Mike Huckabee, who won 13%.