President Bush and Sen. John McCain (Ariz.) put aside their animosity Friday and hugged onstage at a rally for 6,000 soldiers, ending any hopes of some Democrats that the maverick Republican would form a cross-party ticket with Sen. John F. Kerry (D-Mass).

Bush and McCain, whose relations had been at best businesslike since they faced off in the GOP primaries of 2000, praised each other effusively as they appeared on the same podium for the first time in more than four years.

Bush, waving repeatedly to the crowd as he strode onto the stage amid applause, walked straight toward McCain and put his arms around him. The Arizonan leaned his head toward Bush's cheek, and then the president grinned as the senator whispered in his ear.

Officials close to the negotiations said the unexpected detente resulted from concern in Bush's camp about reaching more independent voters and preserving the party's traditional hold on military veterans, coupled with McCain's desire for a legacy as a loyal Republican rather than a prima donna whose dalliance with Kerry gave energy to the Democrat's campaign.

McCain, a prisoner of war in Vietnam for more than five years, took the microphone and spoke emotionally of the "miserable business" of war and "the sublime love of those who sacrifice everything on our behalf" as he recognized two soldiers from the base who were lost in the war on terrorism.

Bush has a strict rule that his introductions last only one minute. McCain went on for eight, but no one from the White House was complaining. "The man I introduce to you today understands all this and understands it very, very well," McCain said. "He heard the call to action on that terrible morning in September and summoned the rest of us to this long and difficult task. He has led this country with moral clarity about the stakes involved and with firm resolve to achieve unconditional victory."

Noting "ups and downs, as there are in any war" and never saying Bush's name, McCain called it "a great privilege to introduce to you your commander in chief."

Bush reciprocated, calling it "a privilege to be introduced to our men and women in uniform by a man who brought such credit to the uniform."

"When he speaks of service and sacrifice, he speaks from experience," Bush said. "The United States military has no better friend in the United States Senate than John McCain."

McCain also introduced Bush several hours later at a rally in Reno, Nev. Bush won the state in 2000 but will have to fight votes for this time because he endorsed a plan to locate a nuclear dump there.

"Both candidates in this race are honored to be the friend of John McCain," Bush said at the rally. "Only one of us gets his vote, and I am proud that it is me."

The last time the two appeared together was in Pittsburgh on May 9, 2000, when the bitterness over the primaries was still raw. McCain agreed with a questioner who suggested that the event was a case of "take your medicine now."

This week's rapprochement resulted from the intervention of Bush's senior adviser, Karl Rove, who is known for his grudges but also for his willingness to do what needs to be done to solve political problems.

In late April or early May, Rove had coffee near the White House with McCain consultant John Weaver, a longtime adversary. Bush's chief ad strategist, Mark McKinnon, joined them. Ten days to two weeks ago, according to the McCain camp, Rove telephoned Weaver and asked whether the senator would appear with Bush at the rally at Fort Lewis, a huge Army base in a state that has the nation's fifth-highest concentration of veterans, and at the afternoon event in Reno.

McCain rearranged his schedule and accepted the invitation within 48 hours, according to his staff. Bush did not call him, but the two met for about 15 minutes at the Fort Lewis lodge where Bush stayed overnight, aides said.

The White House antagonized McCain in 2002 when Bush signed the campaign finance legislation that bears McCain's name without a ceremony, and without informing McCain in advance, denying him the traditional attention that comes from a hard-fought legislative victory.

McCain has occasionally made critical or sarcastic remarks about Bush. In March, he said on ABC's "This Week" that he "might not have used" the image of remains being removed from the World Trade Center that was featured in Bush's first campaign commercial.

Fort Lewis is home of many special operations forces and lighter combat brigades that are part of Bush's plans to transform the military. McCain noted that "26 soldiers who deployed from here have given their lives in this war," including Pat Tillman, the former Arizona Cardinals football player who was killed by "friendly fire" in Afghanistan in April. Bush used the speech for an aggressive defense of his handling of Iraq, saying, "The future of a free Iraq is now coming into view."

McCain sat wedged between two of the 50 soldiers in the front row of the 200-soldier backdrop that the White House had set up behind Bush in a hangar that was so steamy the troops fanned themselves throughout Bush's 38-minute remarks. McCain joined, but did not lead, the 51 interruptions for applause.

Afterward, Bush met privately with 10 wounded soldiers and then spent 21/2 hours with 106 relatives of 28 fallen soldiers. McCain held similar meetings separately, and wept, an official said.

Asked at the end of the day why he was campaigning with Bush, McCain replied, "First time I was asked."

President Bush and Sen. John McCain (R-Ariz.) appear at a rally with 6,000 soldiers in Fort Lewis, Wash. In introducing the president, McCain said, "He has led this country . . . with firm resolve to achieve unconditional victory."