This last fortnight should have marked a celebratory milestone in East Timor's history. After almost seven years, the first two-and-a-half as administrators and then as hands-on advisers, the United Nations was scheduled to have wound up its mission to Asia's youngest nation on May 20.

Instead, the world has witnessed a descent into anarchy and chaos as tribal rivalries in the nascent security forces have exploded into civil unrest that would almost certainly have ripped the nation asunder if more than 2,000 heavily armed Australian-led peacekeepers had not deployed to the capital Dili on May 25.

The killing of 10 unarmed police officers who had surrendered to UN officials by soldiers deemed loyal to the government and the injuring of 27 others, and an enraged mob burning six women and children to death in their home are but two of the more brutal recent incidents.

International aid agencies estimate 40 camps, holding almost 100,000 of Dili's terrified residents, have sprouted in the last few weeks, posing both a potential humanitarian crisis and security nightmare considering their vulnerability to attack.

Far from packing their bags, the UN personnel are now hurriedly making plans for a long-term operation to try and rebuild what was, until April, regarded as the jewel in the international body's nation-building crown.

When East Timor officially declared independence in May 2002, the world descended on Dili to laud its seemingly remarkable transformation from a territory devastated by 24 years of brutal Indonesian occupation to a vibrant fledgling nation well on the road to sustainable development.

"Never before has the world united with such firm resolve to help one small nation establish itself," the UN secretary general, Kofi Annan, said on that day.

Four years on, it is a case of being virtually back to square one.

This time around, reconstruction could be harder than in 1999. Then the nation was united after Indonesian soldiers and their civilian militias destroyed much of the island and killed some 1,200 civilians during and in the wake of the UN-organised referendum through which the East Timorese severed links with Jakarta.

Now the nation is divided between the eastern provinces, known as Lorosae, which means "where the sun rises" in the local Tetum language, and the western areas, or Loromonu, which means "where the sun sets" in Tetum.

The former regard the latter as having been less committed to the independence struggle and so, in the military at least, less worthy of prominent positions.

This was the spark that triggered the current unrest. When soldiers from the west went on strike in March, complaining of discrimination, they were fired. Unfortunately, the government did not confiscate their weapons first, and so the nation found itself in a position of having 600 of the 1,400-strong armed forces staging a rebellion.

The police, many of whom are from the west, were soon sucked into the conflict and rival civilian gangs armed with homemade weapons appeared on the streets shortly afterwards. Foreign troops suppressed the worst of the violence and arson but sporadic clashes and house burning continues.

The Australian prime minister, John Howard, has no doubts as to who is to blame for the carnage. "It came to this path because of poor governance, and the responsibility is on the political leaders of that country," he said at the weekend in an unusually frank criticism of a neighbouring nation's rulers.

"And I have a right as prime minister of Australia, given the commitment we have made, to say to the political leadership it carries a very heavy responsibility, and it's in their hands to deliver a better future for their people."

East Timor's prime minister, Mari Alkatiri, has not handled the situation well. It was he who dismissed the striking soldiers rather than seeking to resolve the situation through talks. But his unpopularity outside the ruling Fretilin party goes deeper than that.

An exile for the Indonesian occupation, he has returned and done little to stimulate economic growth, despite the international community investing more than £1.6bn in the country. Unemployment is running at about 40% and higher amongst the youth, per capita gross domestic product is £200 a year, there are few industries apart from coffee growing and the birth rate is 7.8 per woman, probably the world's highest.

Mr Alkatiri has also alienated many people by insisting on Portuguese, the language of the coloniser who left in 1974, as the official tongue. This is in spite of few people understanding it. Tetum, Indonesian or even English would have been much more appropriate in many people's eyes.

His poor relations with the president, Jose "Xanana" Gusmao, have also proved a contributing factor. Mr Gusamo has little power but, as a hero of the resistance movement against Jakarta, enjoys massive popularity.

The international community, and particularly the UN, cannot escape blame. Development was skewed towards building democratic institutions rather than economic development, with less than 2% of the foreign aid being spent on agriculture.

Foreigners either failed to understand the situation or chose to ignore the problems, as demonstrated by the World Bank's president, Paul Wolfowitz, describing the nation on a visit only weeks before the violence erupted as a "functioning economy and vibrant democracy".

Senior officers in the East Timor defence force were also allowed to run a less-than-professional military.

It is hard to predict what will happen now. The rebels are demanding Mr Alkatiri resign but he has no intention of doing so and can only be fired by parliament, which he controls.

A face-saving compromise will be required but, even though the two sides have started exploratory talks, none appears on the near horizon.

The one major trump card East Timor holds is oil reserves. It is estimated these will add more than £18bn to government coffers over the next decade. If these are spent wisely then "permanent failed state" status can yet be averted.