Ten days ago I sat on a mattress on the floor of a Mahdi army safe house talking to Abu Mahdi, a slim 40-year-old, bearded former Arabic teacher and low level commander in the Shia militia.

I had first encountered him in Najaf in August 2004, when the Mahdi army seized the holy city. Now he boasted of how his comrades were effectively in control of his home town, 200 miles south of Baghdad.

"As we have liberated Amara from the British, Basra is next," he said. "My men are everywhere, can you see the British anywhere? For the people in the street it's my men who rule the town."

Yesterday morning the militia loyal to the Baghdad-based cleric Moqtada al-Sadr demonstrated that fact - and the acute dillemma facing British and American military planners - in the most dramatic fashion.

Residents described how fighters stormed three police stations in this city of 900,000 and blew them up. Around 800 black-clad militiamen with Kalashnikov rifles and rocket-propelled grenades patrolled the streets in commandeered police vehicles as others set up road blocks on routes into the town.

At least 30 policemen and 20 civilians were killed and more than 59 injured in what has become one of the most serious challenges to the authority of the Iraqi prime minister, Nouri al-Maliki.

One Amara resident, Hossam Hussein, said he saw hundreds of gunmen, dressed in the Mahdi army's trademark black uniforms, swarming the city's main streets. "For the last few days, you could smell the trouble building here," he said by phone. "Amara is a battleground between the gangs the militia and the politicians. And sometimes you don't know who is who."

Predicament

Tensions had been rising since five men, including the the brother of a local al-Mahdi militia leader, were allegedly abducted - some say arrested - by police on suspicion of involvement in the killing of a senior police intelligence officer, Qassim al-Tamimi, who was also a member of the rival Badr brigade.

By yesterday British commanders were on standby to re-enter the city they pulled out of two months ago.

Events in Amara vividly illustrate the predicament faced by British troops in Iraq - and offer a glimpse of the country that will be left behind when they are gone. Both protagagnists of yesterday's violence - the Badr brigade and the al-Mahdi militia - are controlled by groups who are nominal partners in the ruling Shia coalition in Baghdad. If the turf wars seen here spread throughout the south it could prove catasrophic for Mr Maliki's attempts to impose order.

The British base nearest to Amara, christened by someone with a keen sense of Iraqi history, was called Camp Abu Naji after the name given by Iraqis to their British colonial masters when they first invaded Iraq back in 1916.

For octogenarian Iraqis the name resonates with law and order, the good old times after the chaos of the Ottoman empire. For younger generations it represents occupation, puppet governments in Baghdad, stiff, tall, blond British officers ordering people around.

At one point, the old army base, fortified with sand barriers and concrete blast walls, was home to 1,300 British and coalition soldiers, tanks, armoured vehicles and three helicopters. Life was never easy. In summer temperatures rose to 60C. On the outskirts and to the north in the city of Amara British troops fought fierce battles in April and August 2004 with the Mahdi Army.

Since the ceasefire two years ago, the militias have gradually taken over Amara through democratic elections and the use of force. The elections organised by the British produced a city council dominated by religious parties affiliated with militias. For more than a year now it has banned any official dealing with British army.

'Stupid'

Meanwhile the militias rained down mortars on the camp daily and ambushed supply lines. According to Lt Col David La Bouchere, commander of the Queens Royal Hussars battle group, around 283 mortars were fired in from last March to August.

The camp needed constant resupplying by around 160 trucks every couple of weeks. "It was a very stupid situation, we needed six to seven companies of soldiers just to protect the base," said Lt Col La Bouchere. "The answer was to leave the base and depend on a more mobile force." When the British left two months ago, officers called it a tactical redeployment; the people of Amara called it a retreat.

The British army said it was handing the base to the Iraqi army which would take responsibility for securing the town. But within a few hours thousands of Iraqis had massed at the gates. Within 48 hours the camp had been looted. "We weren't fair to the Iraqi army, we only told them that we would hand them the base few hours earlier, so they were not prepared," explains Lt Col La Bouchere. "We couldn't trust them to tell them in advance that we were leaving."

After leaving Amara, Lt Col La Bouchere decided to fight the militias their way. Replacing their tanks with soft-topped Land Rovers, they roamed the desert around Amara, using different routes and changing their bases every few days. One of their main missions is to patrol the long Iran/Iraq border trying to intercept smugglers bringing in alleged weapons and improvised explosive devices.

But to militiamen, smugglers and border guards the Abu Naji forces have become little more than players in a soldiering game. "They come, stay for few hours and leave," said one of the guards, on top on a border post. "The smugglers, they only work at night, they come on motorcycles, with no headlights."

Back in his desert camp, sitting on canvas chairs, in front of a big map of the province Lt Col La Bouchere, said: "If you can't get rid of the militia let them counter-balance each other, and they will wither away."

Yesterday's events in Amara suggest that might be wishful thinking.

· Additional reporting by Michael Howard in Sulaymaniya