MANCHESTER, N.H.--Sen. John McCain (R-Ariz.), the 2008 GOP presidential nominee, endorsed Mitt Romney for the 2012 nomination on Wednesday, providing the former Massachusetts governor a potentially crucial boost coming off a narrow 8-vote win in Iowa.

The announcement brought together two longtime Republican rivals, as the veteran senator who failed to reach the White House offered his support to the candidate he had soundly defeated four years earlier.

McCain, who won the New Hampshire primaries in both 2000 and 2008, said he wanted to “make sure we make Mitt Romney the next president of the United States of America.”

“New Hampshire is the state that will catapult him to victory in a very short period of time,” McCain said after being introduced by Romney at a high-school gymnasium. “That's why I’m here.”

McCain, his voice rising, also sharply criticized President Obama, who defeated him in 2008, saying the incumbent had failed to keep his promises to fix the economy and had led the United States to be viewed as weak overseas.

The McCain endorsement came during a fast-moving day of developments that saw one GOP candidate, Rep. Michele Bachmann, withdraw from the race after a disappointing last-place showing in the Iowa caucuses Tuesday night. The top two finishers, Romney and Rick Santorum, moved their fight to New Hampshire.

Bachmann’s fiery rhetoric and social conservatism propelled her to the top of the closely watched Iowa straw poll in August. But she ended up with just 5 percent of the vote in Iowa, a state where she was born and had focused most of her attention.

“I didn’t tell you what the polls said that you wanted to hear. I didn’t tell you what I knew to be false. I didn’t try to spin you,” Bachmann said at a morning news conference in West Des Moines. “Last night, the people of Iowa spoke, with a very clear voice. And so, I have decided to stand aside.”

Texas Gov. Rick Perry, who also surged early in the race, canceled campaign plans Wednesday after garnering only 10 percent of the Iowa vote — despite spending more on advertising in the state than any other candidate. But Perry indicated Wednesday morning that he would head to South Carolina soon to keep campaigning.

“And the next leg of the marathon is the Palmetto State,” Perry wrote in a Twitter message, accompanied by a photo of him in running attire making a thumbs-up gesture. “Here we come South Carolina!!!”

In New Hampshire, Romney and McCain walked toward the stage to the tune, “Highway to the Danger Zone.” Romney delivered a variation of his stump speech before turning to McCain and lavishing praise on the Arizona senator, calling him “one of America’s heroes,” “a great friend” and “a giant among men.”

McCain took the microphone and delivered a full-throated rebuke to Obama: “My friends, our message to President Barack Obama is you can run, but you can’t hide from your record of making this country bankrupt, from destroying our national security and for making this nation one that we have to restore with Mitt Romney as president of the United States of America.”

The duo then took questions from the crowd of more than 300 people as part of New Hampshire’s town-hall tradition. From Manchester, the two were scheduled to campaign in Peterborough, where they would hold another town hall meeting Wednesday evening.

With the New Hampshire primary just six days away, and South Carolina’s primary in less than three weeks, the Iowa results underscore key questions about whether Romney can expand his base of support nationally and whether Santorum — or any other candidate — can muster the funding and organization needed to defeat him.

Romney, who is the front-runner nationally but was not expected to do well in Iowa, won 25 percent of the caucus vote, capturing just eight votes more than Santor­um out of more than 122,000 cast.

“Governor Romney has a big advantage in money and time, and he’s been running for about six years,” said Santorum, a lesser-known former senator from Pennsylvania who campaigned extensively in Iowa but lags far behind Romney in New Hampshire, the former Massachusetts governor’s neighboring state.

“We feel like we can go up there and compete,” Santorum said in an interview with CNN. “We feel very good that we’re going to climb that ladder, just like we did” in Iowa.

Romney told reporters en route to New Hampshire that he was “pretty pleased” with his performance in Iowa but acknowledged the victory was a narrow one. “I think landslides are terrific,” Romney said. “I just didn’t see that in last night’s figures. I’m not sure about you.”

Former House speaker Newt Gingrich (Ga.) was the first candidate to arrive in the Granite State from Iowa, landing on a charter flight before dawn Wednesday and vowing to counter the onslaught of negative advertising that reversed his meteoric rise in Iowa and left him limping to a fourth-place, 13 percent finish. In third place was Texas Rep. Ron Paul, with 21 percent of the vote.

“We were on a path to have a real policy debate ... and then we got diverted by Romney and his negative campaign, and also Ron Paul, to some extent,” Gingrich said on MSNBC Wednesday morning. “So now we have to go back and figure out how we are going to run in an environment where clearly you have two guys who are willing to say things that are not honest, and who have millions of dollars to pay for doing so.”

Bachmann, who was born in Iowa and was counting on a strong showing there, had previously planned to fly to South Carolina to campaign. Instead, in a rambling and sometimes emotional farewell address, she railed against President Obama’s health-care and financial reform laws and said Republicans must unify behind one candidate — though she did not endorse anyone herself.

“I ran to secure the promise of our children’s future,” Bachmann said. “And so I decided to stand up — stand up and fight for our children’s future. President Obama and his socialist policies must be stopped.”

In New Hampshire, the candidates who survived the Iowa caucuses will also be competing against former Utah governor Jon Huntsman Jr., who chose not to campaign in Iowa in order to focus more attention and resources in New Hampshire.

Appearing on MSNBC Wednesday morning, Huntsman called the Iowa results “unbelievably ambiguous” and said that “a lot of people are still looking for an alternative. ... They want new leadership.”

Though Santorum’s old-fashioned, shoe-leather approach to campaigning paid off in Iowa, the question now is how far he can go from here, given his lack of resources and the need to ramp up a national organization.

Santorum also will come under the kind of scrutiny and criticism that he was spared when the other contenders did not view him as a threat. Paul, for instance, has already branded Santorum “very liberal,” and Perry has described the former senator as “addicted to earmarks.” For his part, Santorum has said Paul is “disgusting,” and he blamed Paul’s campaign for automated phone calls in which voters were told that the vehemently antiabortion Santorum was, instead, more supportive of abortion rights.

Though Romney’s Iowa vote percentage was almost precisely what he got in 2008, the fragmentation of the field meant that he was spared the kind of defeat he suffered four years ago. This time, he had made a far more modest effort in the state. As he noted Tuesday night, his Iowa staff of five was less than one-tenth the size of his operation in 2008.

And both Paul, a libertarian whose views are out of line with those of most Republicans, and Santorum, an underfinanced social conservative, will struggle to prevail against Romney in the long run.

But the results also point to the fact that the Republican base remains deeply dissatisfied with Romney, whose moderate record has engendered mistrust among conservatives.

They appear unconvinced by Romney’s argument that he is the most electable of the candidates, and that his record as a business executive and corporate turnaround artist would be the ideal contrast against a vulnerable incumbent president whose chief liability is an ailing economy.

But it appears that for the first time in this campaign, Romney is about to come under intense attack by his opponents, which could further roil — and prolong — the race.

Gingrich, whose political career has been defined by a take-no-prisoners approach to his adversaries, has until recently refrained from criticizing the front-runner. But over the past few days, he has taken a sharply negative tone — one that he appears certain to amplify as the contest moves forward. In an interview Tuesday on CBS, he called Romney “a liar.”

His campaign bought a full-page ad in Wednesday’s Manchester, N.H, Union-Leader headlined “The Choice.” It describes the former speaker as a “Bold Reagan Conservative,” and Romney as a “Timid Massachusetts Moderate.”

For all the attention the Iowa caucuses receive as the first contest of the nominating season, they have been an unreliable predictor of which GOP candidate will ultimately receive the nomination in races where there is not an incumbent president.

Since the caucuses first rose to prominence in the 1970s, only two winners — Sen. Robert J. Dole in 1996 and Texas Gov. George W. Bush — have gone on to become their party’s standard-bearers.

Past Iowa contests have, however, cleared the field of its weaker performers such as Bachmann. The next potential casualty is Perry, who entered with great fanfare in August, quickly rising to the top of the polls and raising millions. Perry proved to be a disaster in debates, however, in a year when those nationally televised forums played an outsized role in the primary race.

The three candidates in the top tier have distinct constituencies, ones that echo broader divisions within the GOP.

Caucus-night polling suggests that Romney was the strongest performer among voters whose top priority is beating Obama. According to preliminary num­bers, he won nearly half of all such voters, more than double the number selecting any other candidate.

Romney also fared relatively well among moderates and liberals, even as he slipped among the most conservative caucus-goers compared with his performance four years ago.

Caucus-goers who described themselves as “very conservative” broke for Santorum, according to the polling. The former senator also emerged as the newest darling of the tea party political movement, picking up 30 percent of strong tea party backers, with four other candidates in the teens.

The senator surged in the closing days of the campaign and won a plurality among those saying they made their final decision on Tuesday.

Paul, who won only one Iowa county in 2008, was buoyed by strong support among younger voters and independents, with both groups making up a larger share of caucus-goers than they did four years ago.

Rucker reported from New Hampshire. Polling director Jon Cohen in Washington and staff writers Amy Gardner, Rosalind S. Helderman, Nia-Malika Henderson and Karen Tumulty in Iowa and New Hampshire contributed to this report.