The gunfire built to a steady rhythm. American soldiers in a Stryker armoured vehicle fired from one end of the block. At the other end, two groups of Shia militiamen pounded back with machine guns and rocket-propelled grenades. US helicopters circled above in the blue afternoon sky.

As a barrage erupted outside his parents' house, Abu Mustafa al-Thahabi, adviser to the Mahdi army of Shia cleric Moqtada al-Sadr, rushed through the gate to take shelter. He had just spoken with a fighter by mobile phone. 'I told him not to use that weapon. It's not effective,' he said, talking of the rocket-propelled grenade. 'I told him to use the IED, the Iranian one,' he added, referring to an improvised explosive device. 'This is more effective.'

After nearly a year of relative calm, US troops and Shia militia engaged in pitched battles last week, underscoring how quickly order can give way to chaos in Iraq. On this block in Sadr City, the cleric's sprawling stronghold, armed men and boys came out from nearly every house to fight. From Thursday afternoon to Friday morning, this correspondent spent 19 hours here, at times trapped by intense crossfire inside the house of Thahabi's parents. Fighters engaged US forces for seven hours. They lost a comrade. They launched rockets into the Green Zone. Around the same time, rockets killed a US government employee, the second American killed there last week.

Between battles, fighters spoke about politics and war. There was no sign of grief or fear. Death was a short cut to some divine place. As the two sides exchanged fire, Thahabi's mother, Um Falah, clutched a Koran and began to pray to Imam Ali, Shia Islam's most revered saint. Her eldest son, Abu Hassan, is a Mahdi army commander.

Earlier that morning, Sadr City had been eerily quiet. Cars moved slowly. Residents ferried food and water, preparing for the worst. Rubbish littered the charred streets. On one road, two green Stryker vehicles were parked.

Outside Um Falah's house, Mahdi fighters gathered, standing against the walls, peering down the street. Clashes were unfolding on an adjacent road. One group joined the fighting, but the others remained in place. Their job was to protect their end of the block. Um Falah continued her chores: 'I have got used to war, to all the battles in our lives.' It was not the first time her son had gone to fight US troops and in her heart, she said, she knew it would not be the last. 'I have sent my son on the right path,' she said.

In their living room, her husband and Abu Mustafa sat on red carpets set with colourful pillows. The room was prepared for battle, with plastic windowpanes and drawn curtains. On the wall hung tapestries depicting Imam Ali and other saints.

Thahabi, slim and gaunt-faced, said the Mahdi were not fighting only the Americans but also their Shia rivals - the Islamic Supreme Council of Iraq and the ruling Dawa party. Thahabi believes the government launched an offensive in Basra last Monday to weaken the Sadrist forces ahead of provincial elections scheduled for this year. He thought Iraqi Prime Minister Nouri al-Maliki, who leads the Dawa party, was taking advantage of a ceasefire imposed by Sadr last August.

Iraq's government said it began the offensive to wipe out Basra's Shia militias and criminal gangs. 'They know the Sadrists will win the elections,' Thahabi said. 'So they are using the Americans against the Mahdi army. People have reached a point that they will sell their refrigerator to buy a rocket launcher to kill Americans.'

At around 2pm, three solemn-faced fighters entered the room, fresh from battle. 'Akeel, son of Riad, just got killed,' said Abu Zainab al-Kabi. The room fell silent. Kabi, 34, said Akeel had been planting a roadside bomb when he was shot several times by a US soldier. Akeel was 22 and had followed his father and uncle into the Mahdi army when he was 17. The fighters took his body to the hospital mortuary. If they could break away from the battle, they planned to carry it on Friday to the southern holy city of Najaf, where the Mahdi has built a cemetery for their dead, their martyrs.

'We are proud that he died,' said Abu Moussa al-Sadr, 31. 'Whenever one of us dies, it raises our morale.'

'It intensifies our fighting. If we defeat them, we win,' Kabi said. 'If we die, we win.'

Signs of sorrow for Akeel soon vanished; they wanted to eat lunch. Over a spartan meal of bread, tomato paste and vegetables, they said they had woken before dawn to make sure all their fighters were in position. They ordered their men to check all the IEDs they had set and shared intelligence with commanders in other sections of Sadr City. Suddenly, they heard mortar rounds being launched outside with a boom like the sound of a wrecking ball.

'This is to the Green Zone,' said Kabi. 'These are gifts to Maliki's government.' He and Abu Moussa al-Sadr both work for Iraq's Ministry of Interior, which runs the police and is viewed as infiltrated by the Mahdi army. They said many police officers had defected and were now fighting with the Mahdi army.

The fighters also said they received neither support nor training from Iran, as American military commanders allege. Their Iranian weapons, they said, were bought from smugglers. They said they had been fighting only Americans and had not engaged with any Iraqi forces and insisted they were still obeying Sadr's cease-fire and would stop fighting if he gave the order. 'We are allowed to defend ourselves,' said fighter Abu Nargis.

Around 3pm, it was time to leave. 'We're going to the hospital to see Akeel's body,' Abu Moussa al-Sadr said. 'Then we are going back to fight.' An hour later, another group were fighting US troops. Militiamen jumped into the street, then quickly vanished. The quick movements were a tactic. Outside his parents' house, Thahabi explained that fighters would direct a barrage of bullets at the Stryker to distract the soldiers while another group tried to slip a bomb under the vehicle.

A father of four who studied psychology in college, Thahabi looked more like a professor than a militia adviser. He clutched three mobile phones, each using a different network. When the Americans drive by, they jam the signals of the main network provider to neutralise the use of phones as detonators.

The fighters' larger strategy, Thahabi said, was to draw pressure away from the Mahdi army in Basra. Many Iraqi soldiers fighting in Basra had families in Sadr City. 'They will be worried for their families. They will fear what will happen to them. It's about reducing morale.'

Thahabi received a phone call. 'The whole block has been surrounded by the Americans,' he said.

Targeting the Green Zone, at 5.25pm, the Mahdi army fired at least 10 rockets from near the house. Within 20 minutes, four more were launched. The rocket launches were followed by heavy gunfire at the Stryker.

'We have to keep the Americans nervous, on their edge,' Thahabi said. 'We can't make it easy for them.'

Someone told him that there was a sniper on a nearby roof. After a silent pause, fighters sprayed a burst of gunfire at a roof; bullets tore into the wall. Then silence again. A few minutes later, gunfire was returned in the direction of the fighters. The Americans were still around.

'They are facing heavy resistance," said Abu Nargis. He carried his baby daughter. 'They will raid the area tonight.' By 7pm, the Stryker had left.

At 9.05pm, Abu Nargis received a phone call. He said he had been told that a police commander with 500 men would stop working with the government and join the Mahdi.

At 9.09pm, screams tore through the street. A woman in a black abaya was walking toward the hospital wailing: 'My mother! My mother!' Her house had been hit, it was not clear by whom. Ambulances and police vehicles drove past the house as an unmanned US drone flew by. The vehicles drove back, carrying dead and injured.

At 10:35pm, Abu Nargis received another phone call. 'The Americans are gone. Even the snipers,' he said. 'I have to go and check on my daughter. She's afraid of the gunfire.'

Next morning, Kabi was standing on a nearby street with a group of fighters, including two boys who looked no older than 13. They were getting instructions from an older fighter, who clutched an AK-47 assault rifle. They looked weary.

At the edge of Sadr City, four Strykers rolled by. A white car waited patiently for the convoy to pass, then drove out, a wooden coffin strapped to the top.