FALLUJAH, Iraq — A single week in this restive town illuminated the triumphs and setbacks in Iraq's journey toward democracy.

Under threat by anti-American insurgents, the mayor resigned. Another man suspected of cooperating with the Americans was gunned down in front of his home. A sheik elected to the new provincial council was attacked by a suicide bomber. The American adviser survived a bomb attack on his car. And on Saturday, attackers stormed a police station, freeing dozens of prisoners in a raid that left more than 20 people dead and at least 40 others wounded.

Yet for all of that, when the Americans held a caucus here to choose a new provincial council, more than 1,000 people turned out to vote, crowding into a youth center and debating well into the night.

The next day, the new council members attended an inauguration ceremony that went off without a hitch. Even when interrupted by a gunbattle on Thursday, the Fallujah Town Council refused to give up.

"Every time we meet here with the Americans we have problems like this," Dr. Muhammad al-Balwa, the council president, told his colleagues. "Next time we will meet outside the city, but until then we will keep going."

The first days of Iraqi self-governance are unfolding: a caucus here, a bomb blast there, an assassination, a resignation, yet youth centers are packed full of Iraqis eager to give voice to their dreams.

The same scene is unfolding across the country, following a directive by Iraqi and U.S. officials to hold fresh caucuses in the 19 provincial councils and in the 250 city councils, to elect new members to replace those who had been U.S. appointees in the first days after the war.

In a way, it is an enormous warm-up act: The provincial councils are expected to play a crucial role in the process by which the Americans are to transfer sovereignty by June 30. The caucuses are expected to be the principal means by which Iraqis will select the members of their new National Assembly.

Nowhere is the experiment more difficult than in Fallujah, a hardscrabble town about 35 miles west of Baghdad where many residents directly benefited from Saddam Hussein's rule. Here, the American-inspired effort must try to set up working democratic institutions while a guerrilla war still smolders.

The push to install a democracy here is strained by a bitterness expressed by many Fallujah residents. It is not so much antidemocratic as anti-American.

The Americans insist that they will succeed, that their troops will crush the insurgency as democratic institutions take hold. Military officers and civilian advisers say they are encouraged by the desire for self-government on the part of the Iraqis, something that was repressed for so long by Saddam's iron hand.

"There is enormous hunger here for democracy," said Keith Mines, one of the advisers. "You can see it when you go to these caucuses."

Indeed, the scene at the Fallujah Youth Center last week seemed a validation of every idealistic notion that democracy could take root in a land that has never known it. At the first of the day's three caucuses, the city's legal community gathered to choose their representative for the new Anbar Provincial Council.

By 10 a.m., about 200 lawyers had crowded into the auditorium, many of them dressed in Western-style coats and ties, and barely a seat was to be had. The candidates rose to nominate themselves. One of the first was Sabah Naji, who climbed up on the stage to ask for support among people he already knew well.

"If you believe that I am the better candidate, then I ask that you vote for me," Sabah told his colleagues. "And if

you think my opponent is the better man, vote for him."

After Sabah's opponent, Saidullah Mahdi, finished a similar speech, the chairman of the caucus, Muhanad Ismail, made an unexpected announcement.

"An objection has been raised by someone in the audience that Mr. Sabah was a high-ranking member of the Baathist Party," Ismail said. Sabah, it was said, had been a shuba, a senior party member.

A murmur swept through the crowd, but Ismail had more to say. "But I also have in my possession a Baath Party document listing the names of party members who were regarded as disloyal and unenthusiastic," he said. "And Mr. Sabah's name is here on that list."

A man stood up in the audience.

"Mr. Sabah was expelled from the Baath Party just before the war," the man said. "I know that to be true."

With that, Ismail overruled the objection, and the lawyers voted. Each person in the room wrote down the name of his or her preferred candidate on a piece of paper stamped with the official seal of Al Anbar Province. Then they dropped their ballots into a large box.

When the votes were tallied on the blackboard, Sabah, the Baath Party man, bested Saidullah by a wide margin. Afterward, many of the lawyers said they had chosen Sabah for his youth and energy, and that his ties to Saddam's former party did not matter much.

"What's the big deal?" Abdul Satar, one of the lawyers, said. "Just about everyone here was a member of the Baath Party. And anyway, they kicked him out."

Satar said most people in Fallujah, and most people in Iraq, yearned to govern themselves. But his volubility stopped when the subject came to the insurgents. Asked who they were, two of his companions began to speak, but Satar cut them short.

"Shut up, I know what I am going to tell him," he told his companions in Arabic, not realizing, apparently, that he would be understood.

He turned to a visitor.

"It is foreigners who are doing these attacks," Satar smiled, "not the Iraqis."

The tentative success of the caucuses is only part of the story of democracy in Fallujah. For every candidate standing for office, and for every translator or contractor who decides to work with the Americans, there is the constant threat of death.

A spray-painted banner on a wall of the Fallujah Primary School announces the menace: "Anyone who helps the Americans in any way is a dirty traitor, and that person is worth killing."

In July, a platoon of American soldiers patrolling Fallujah unexpectedly met an angry throng of Iraqis.

The Americans ducked into a walled compound of Sadoon Shukar Mahmood, a 48-year-old father of seven, to avoid a confrontation. After a time, the crowd passed. The next day, the soldiers pulled up in an armored personnel carrier to thank Mahmood, and they handed out candy to his children.

Three months later, leaflets began arriving on Mahmood's doorstep, threatening him with death for buddying up to the Americans.

Two weeks ago, the leaflets started coming again, but Mahmood brushed them off, assuring himself and his family he had nothing to fear.

Last Thursday, a few days after another of the leaflets had been dropped by his door, Mahmood stepped into the street to buy eggs and cream for breakfast. A yellow sedan with license plates pulled up next to him, his family members said. Two masked men opened fire; Mahmood died in the street.

"People thought he was cooperating with the Americans," Dari Abu Hassan, Mahmood's cousin, said. "But he was not. He was not."

Such attacks are common. On Tuesday, after the inauguration of the Anbar Provincial Council, a suicide bomber blew himself up at the home of Sheik Majid Ali Sulieman, a tribal leader who had been elected to the council in nearby Ramadi. His guards shoved the bomber out the front door just as he exploded.

The next day, a bomb exploded underneath the car of Stuart Jones, an American who is the political adviser to the local councils in Anbar Province. Jones was fortunate to be driving in the only armored vehicle in his convoy.

"It felt like we hit a deer," he said.

In Fallujah, as in any fragile democracy, the system will probably survive only if the losers accept the results. One powerful sheik spent much of the week trying to do just that.

Sheik Ghazi Sami al-Abid emerged triumphant from an early caucus that was set up without the approval of the Americans. When the Americans approved the second one, Sheik Ghazi lost.

He contested the election with the anger of someone not used to losing, but his appeal failed both before the Iraqis and Americans.

"I am a wealthy man, a rich man, I deserve to be elected," the sheik said over lunch at his sprawling estate at the end of the week. "And some little money-changer comes along and beats me."

He paused, and then smiled as if a revelation had come to him.

"I guess that's American-style democracy, isn't it?"