It is part of a general decline in violence that is resonating in American as well as Iraqi politics: Senator John McCain argues that the advances in Iraq would have been impossible without the increase in American troops known as the surge, while Senator Barack Obama, who opposed the increase, says the security improvements should allow a faster withdrawal of combat troops.

The Mahdi Army’s decline also means that the Iraqi state, all but impotent in the early years of the war, has begun to act the part, taking over delivery of some services and control of some neighborhoods.

“The Iraqi government broke their branches and took down their tree,” said Abu Amjad, a civil servant who lives in the northern Baghdad district of Sadr City, once seen as an unbreachable stronghold for the group.

The change is showing up in the lives of ordinary people. The price of cooking gas is less than a fifth of what it was when the militia controlled local gas stations, and kerosene for heating has also become much less expensive. In interviews, 17 Iraqis, including municipal officials, gas station workers and residents, described a pattern in which the militia’s control over the local economy and public services had ebbed. Merchants say they no longer have to pay protection money to militiamen. In some cases, employees with allegiances to the militia have been fired or transferred. Despite the militia’s weakened state, none of the Iraqis interviewed agreed to have their full names published for fear of retribution.

In a further sign of weakness, Shiite tribes in several neighborhoods are asking for compensation from militia members’ families for past wrongs.