Giuliani's withdrawal leaves McCain facing a strong challenge from Mitt Romney, the former Massachusetts governor.
Mike Huckabee, the former Arkansas governor, is still formally in the Republican race, but his lack of campaign money and limited appeal beyond Christian conservatives has left him trailing far behind.
Giuliani made his announcement before a Republican debate at the Ronald Reagan Presidential Library in Simi Valley, California, on Wednesday night.
In a further boost for McCain, rival Romney signalled on Wednesday that he was not ready to commit to a costly campaign in the states holding primaries and caucuses next week.
Several officials said Romney's campaign was not attempting to buy television advertising time in any of the nearly two-dozen states holding elections on February 5, known as "Super Tuesday".
Instead, the former Massachusetts governor's current plans call for campaigning in several primary states, including California.
But he has his work cut out in the state where the governor, Arnold Schwarzenegger, looks very likely to endorse McCain.
Senior aides said on Wednesday that the governor will make his endorsement official on Thursday.
Steve Schmidt, a senior McCain adviser who managed Schwarzenegger's campaign to be governor in 2006, called the former film actor an "exceptional governor" on Wednesday.
"We are honoured that he has decided to endorse Senator McCain, and look forward to the event tomorrow," he said.
'Stepping aside for history'
Also on Wednesday, Edwards travelled to New Orleans, where he launched his campaign more than a year ago, to make the surprise announcement that he was ending his campaign.
"It is time for me to step aside so that history can blaze its path," said Edwards, speaking in an area devastated by Hurricane Katrina in 2005.
Edwards had not won a single primary or caucus and had consistently polled third behind Democratic rivals Hillary Clinton and Barack Obama.
Edwards has not said if he will
endorse Clinton or Obama [AFP]
Reacting to the news, Obama praised Edwards on Wednesday for spending a "lifetime fighting to give voice to the voiceless and hope to the struggling, even when it wasn't popular to do".
Clinton told NBC that it was crucial to remember the "very important" contribution Edwards made "to encourage us to focus on poverty".
Edwards did not indicate whether he would endorse either Obama or Clinton for the nomination. Such a seal of approval could boost either one's campaign.
Edwards made the decision to run for the nomination despite his wife's cancer recurring last year.
A former trial lawyer, he focused on US poverty.
He ran for the Democratic presidential nomination in 2004 and after losing was picked by John Kerry as his prospective vice-president in that year's White House race which Kerry lost to George Bush.