The disturbing United Nations report on how it handled the final stages of Sri Lanka's civil war, goes to the heart of what the UN is for, writes Callum Macrae, director of Sri Lanka's Killing Fields.

UN must learn lessons of Sri Lanka tragedy.

The lessons learned from the report will be fundamental if the UN is to make sure it does not make these mistakes again.

At the heart of the matter lies the central notion of the "the responsibility to protect". That is, in effect, why the United Nations exists. It was set up to make sure these kinds of massacres never happen again - and it has failed.

To understand why, we have to look at what happened in Sri Lanka at the end of the war in 2008-9.

As the Sri Lankan government prepared for its final bloody offensive against the Tamil Tiger rebels, it took every step it could to ensure there would be no witnesses to what was to come. It kicked out international journalists from the war zone, it effectively gagged local journalists: in the past few years literally dozens of Sri Lankan journalists critical of the government, both Singala and Tamil, have disappeared, been exiled or died.

But the next, critical step was to kick the UN and other international workers out of the war zone by saying they could no longer guarantee their safety. Many of the UN workers on the ground in the north were horrified by the order to pull out. They believed - correctly, as it turned out - that without them there, the government would have a licence to massacre with impunity.

We know now that many UN staff were carefully compiling the evidence of the slaughter - but the UN's high command failed to make that information public.

Many of them were willing to risk their lives and stay - if necessary to travel with the internal refugees - to ensure that international eyes were still on the ground and to restrict the Sri Lankan government's apparently murderous intent. They were not allowed to.

Having withdrawn from the war zone, the UN effectively retreated to the safety of Colombo where they watched and, indeed, carefully recorded the scale of the ongoing slaughter. We know now that many UN staff were carefully compiling the evidence of the slaughter - but the UN's high command failed to make that information public.

Watch on 4OD: Sri Lanka's Killing Fields

The argument was that if they shouted and screamed about the scale of the slaughter, they would be kicked out completely from the country in which they were guests, and that instead they should restrict themselves to quiet diplomacy.

But many - including many within the UN - argue that if it had gone on the offensive, publicly and loudly about the scale of the massacre it knew was going on, it might have brought greater pressure from the rest of the world on Sri Lanka to stop the war crimes.

And even if the only effect had been to draw the attention of the world to the crimes at the cost of being kicked out, that would have been a far better result, and the UN's fundamental purpose and duty would seem far less tarnished.

The effect of this was not just neutral. By remaining there and turning a blind eye, except in private, the UN risked becoming part of the veil of secrecy behind which these crimes were committed. However inadvertently it helped provide a respectable cover for the government and its policy.

So what lessons should the UN draw? It comes back, as always, to the UN's fundamental duty to protect. In this case the UN's desire to stay in the country - and to stay within the boundaries of behaviour acceptable to the government of that country - was allowed to supersede its duty to protect the civilians of that country.

Perhaps that should be the real lesson of this tragedy: that the UN must accept its duty to protect civilians, and the innocent on the ground must always come above its duty not to fall out with individual governments.

Click to download full UN report - Internal Review Panel on United Nations action in Sri Lanka

That is a difficult lesson to learn and, yes, a risky one to implement. But if it is not learnt, then these tragedies will happen again - and the world may begin to question its purpose.

In the meantime - say the critics - there is work to be done. The dead - perhaps as many as 40,000, perhaps many more - cannot be brought back now. But the UN can at least make sure that it pursues, with uncharacteristic vigour, the search for some kind if international mechanism to investigate responsibility for what happened and ensure justice is brought to both the victims and perpetrators of these crimes.

Callum Macrae is a writer and director, and was director of the award-winning Sri Lanka's Killing Fields. He is currently working on a feature documentary about the events in the Sri Lankan civil war. Follow @Callum_Macrae Twitter.