Race is also a consideration. Muhammad Ahmed Kareem, 49, an engineer from Mosul, said he had high expectations of Mr. Obama because his experience as a black man in America might give him more empathy for others who feel oppressed by a powerful West. “Blacks suffered a lot of discrimination, much like Arabs,” Mr. Kareem said. “That’s why we expect that his tenure will be much better.”

But Mr. Obama also frames the sometimes contradictory feelings Iraqis have about America as the withdrawal of troops has moved closer to the political mainstream in both countries. Already, the units brought in for the so-called surge last year have left, and the Bush administration has in recent days acknowledged the need both to transfer troops from Iraq to an ever-more-volatile Afghanistan and to recognize that a broader withdrawal is an “aspirational goal” for Iraqis.

Mr. Obama has advocated a withdrawal that would remove most combat troops from Iraq within 16 months of taking office. Despite some fears about such a departure, that stance is not unpopular here. Many Iraqis hate American forces because soldiers have killed their relatives and friends, and they say they want the troops out.

“Of course I want the American forces to leave Iraq,” said May Adnan Yunis, whose sister was killed, along with a female and a male co-worker, when they were gunned down by American soldiers while driving to work at Baghdad International Airport three weeks ago. “I want them to go to hell.”

After the killings, a statement by the American military describing the three employees as “criminals” who shot at the soldiers inflamed Iraqi officials even more. In a rare public rebuke of the American military, the Iraqi armed forces general command described the American soldiers’ actions as crimes “committed in cold blood.”

For General Hiti, who commands a swath of western Baghdad, the American military is a necessary, if vexing, presence. He ticks off the ways it helps: evacuating wounded Iraqi soldiers, bringing in helicopters when things go wrong, defusing bombs, getting detailed pictures of areas from drone planes.

But the issue of withdrawal is immensely complex, and some of the functions mentioned by General Hiti would not be affected under Mr. Obama’s plan. The senator is calling for the withdrawal of combat brigades, but has said a residual force would still pursue extremist militants, protect American troops and train Iraqi security forces.