At a sensitive moment in the U.S. presidential campaign, the Bush administration is promoting the tentative success of Afghanistan's election as a hopeful model for Iraq's future: a messy, often violent struggle against extremists that has nevertheless produced democratic elections.

The agreement yesterday by Afghan opposition candidates not to boycott the results, despite allegations of irregularities, marks a welcome moment in a tough year for the administration in Iraq and for U.S. diplomacy in the Islamic world.

In Macedonia yesterday, Defense Secretary Donald H. Rumsfeld called the Afghan voting on Saturday "breathtaking. The great sweep of human history is for freedom. We see that in this region, we have seen it in Afghanistan, and let there be no doubt we are going to see it in Iraq."

At the same time, analysts and some U.S. officials debate just how much similarity there is between the two countries -- and their potential outcomes.

Foreign policy analysts observed that Afghanistan differs from Iraq in security challenges, reconstruction efforts and political history -- notably, Afghanistan's experiment with open elections in 1965 and 1969 during the monarchy, which helped give Afghans a new appetite for democracy. Since its creation after World War I and the fall of the Ottoman Empire, Iraq has never held democratic elections, they noted.

Analysts also say the results in Afghanistan -- and the compromise that prevented a threatened boycott by all 15 opposition candidates for president -- are largely attributable to an Afghan thirst to end the era of civil strife. No international intervention could produce those results unless Afghans had been eager to participate, they said.

"This election had two major messages. First, Afghans believe they have a right to participate in their government, that it's their legacy after 30 years of violence," said Thomas E. Gouttierre, who just returned from Kabul and directs the University of Nebraska's Center for Afghanistan Studies. "The results will also carry a message to jihadis: Thanks for what you did against the Soviets, but we want to turn a new page and have another group of leaders for our future."

Those factors were reflected in the compromise, negotiated by U.N. and U.S. envoys, to let an independent commission investigate alleged irregularities.

Gouttierre said the administration deserves praise for "a step well taken and well delivered." But he also credited major roles by the international community, both in security efforts and election preparation by the United Nations.

In the U.S. campaign and two debates, President Bush has faced intense criticism for his strategy in Afghanistan. Democratic candidate Sen. John F. Kerry charged in a speech at Temple University last month that Bush has made several bad choices, first in rushing to a new war in Iraq before wrapping up the fight against the Taliban and Osama bin Laden, and then when Bush "outsourced" the job to Afghan warlords, who let bin Laden slip away.

At the second debate, last Friday, Kerry also said that Bush's strategy had failed because Afghan elections had been repeatedly postponed, because 75 percent of the world's opium production now comes from Afghanistan, and because more Americans died last year in the country than the year before.

"He's got 10 times the number of troops in Iraq than he has in Afghanistan, where Osama bin Laden is. Does that mean that Saddam Hussein was 10 times more important than Osama bin Laden?" Kerry said. "I don't think so." Afghanistan, not Iraq, should be the focus of the war on terrorism, he added.

But the White House cited the voting in Afghanistan as a validation of the president's strategy on terrorism and Iraq. Democracy is "truly the way to replace the source of terror over the long term," said James R. Wilkinson, deputy national security adviser for communications.

"This election was held in a country where freedom is a new concept. Clearly freedom is also a new concept in Iraq and clearly this election shows that those across the broader Middle East who've never had the vote are eager to cast their vote," he added.

A senior State Department official familiar with policy in both countries said the voting proved that it is possible to move from a society gripped by terror to democracy in a relatively short time. In June, when voter registration was launched, he noted, analysts predicted intimidation and limited security would prevent the majority from signing up. Instead, more than 10 million people registered and more than half voted.

Yet experts on Afghanistan caution that, on many counts, the presidential election is not a fair test of whether democracy is taking deep root. The poll and its aftermath are a success but not a final victory because the Taliban and narcotics traders are still thriving and the political playing field was not even, said Husain Haqqani, a fellow at the Carnegie Endowment for International Peace. Hamid Karzai, the interim president and likely winner of the vote, was widely seen as the guarantor of U.S. aid, which led voters to turn to him less for his platform than as an intermediary for donors, on whom Afghans heavily rely.

"Basically, the results ensure that the process moves forward without changing anything," Haqqani said. Yet to be seen is whether parliamentary elections, postponed until spring, are successful, or whether they place so many warlords and drug merchants in the new assembly that Afghanistan becomes a Central Asian version of Colombia, he said. And the real test will be if democracy can be sustained after the day-to-day U.S. involvement ends.

"The election is in the right direction," Haqqani said. "But the way it is being projected by the Bush administration to the American public for political purposes does not reflect the complex reality."

Staff writer Thomas E. Ricks and researcher Lucy Shackelford contributed to this report.