Image copyright AFP Image caption The fate of thousands of Tamils has been in question since the final stages of the war

The United Nations has called for a special court to try war crimes committed during the Sri Lankan army's long conflict with Tamil Tiger rebels.

In a long-awaited report, the UN human rights office accused both sides of atrocities, especially during the final stages of the war in 2009.

In response Sri Lanka promised a local inquiry but will not allow the proposed court, which would have foreign judges.

One UN estimate is that 40,000 Tamils died in the final army offensive.

Analysis: Charles Haviland, former BBC correspondent in Colombo

In the government's reaction to the report, there appears to be one major shift. Cabinet spokesman Rajitha Senaratne told the BBC that ex-President Rajapaksa and his family would not necessarily be protected if there were allegations of serious crimes against them.

"Where even the president or other commanders or defence secretaries - whoever - is involved, our government is ready to take action."

But otherwise Colombo is sticking to its line that a Sri Lankan process, with nothing more international than advice, will suffice. He said a series of domestic commissions, including a South Africa-style Truth Commission, will be set up "to clear the name of the country".

That is not compatible with the hard-hitting UN report. Its main thrust is that a hybrid - part-international, part-Sri Lankan - tribunal is needed, because "years of denials and cover-ups" mean the Sri Lankan system is "not yet ready to handle these types of crime".

Media playback is unsupported on your device Media caption The 26-year war left at least 100,000 people dead (This report was first broadcast in May 2009)

Earlier this week Sri Lanka's new government unveiled plans to set up a truth and reconciliation commission to examine war crimes allegations, including those against the military.

The previous government of President Mahinda Rajapaksa had resisted international pressure to investigate the issue.

Sexual violence and torture

Unveiling the report in Geneva, UN Commissioner for Human Rights Zeid Ra'ad Al Hussein said only a special court with international magistrates and investigators would be up to the huge task of examining the alleged crimes over a nine year period up to 2011.

Image copyright AFP Image caption Hundreds of thousands of Tamils were trapped on a patch of land at the end of the war

Image copyright AFP Image caption Many Tamils are still homeless after the war - countless others are missing

"Our investigation has laid bare the horrific level of violations and abuses that occurred in Sri Lanka, including indiscriminate shelling, extrajudicial killings, enforced disappearances, harrowing accounts of torture and sexual violence, recruitment of children and other grave crimes," he said.

He also called on the Sri Lankan government to remove from office anyone if there were credible grounds to believe they had committed human rights abuses.

The report's main findings include:

numerous unlawful killings between 2002 and 2011, allegedly by both sides

enforced disappearances affecting tens of thousands over decades

the "brutal use of torture" by security forces, in particular during the immediate aftermath of the conflict

extensive sexual violence against detainees by the security forces "with men as likely to be victims as women"

forced recruitment of adults and children by the rebels, particularly towards the end of the conflict

The report said forced recruitment by the rebels would, if proven in court, be a war crime. The denial of humanitarian assistance - which it said the government might be guilty of - could also constitute a war crime.

Senior Sri Lankan minister Rajitha Senaratne told the BBC: "Our stand on war crimes is we need an internationally accepted local inquiry. We are not ready to agree with the international inquiries."

Despite its promises to pursue accountability, the government elected last month would be reluctant to hold war-crimes trials, correspondents say.

Image copyright AP Image caption Both sides are accused of widespread atrocities over many years

The BBC's Azzam Ameen in Colombo says most among the majority Sinhalese community opposed prosecuting troops.

Some Tamil politicians in the north back a UN-led inquiry and say they have no faith in a domestic process.

The final months of the war saw hundreds of thousands of Tamil civilians trapped in territory held by the Tamil Tigers (LTTE) in the north-east.

While government forces were accused of indiscriminate shelling leading to massive casualties, the Tamil Tiger rebels were alleged to have used civilians as human shields and shot people trying to escape.

Allegations persist to this day that the army killed rebel leaders and others after they surrendered or were captured - and the UN admitted in 2012 that it could and should have done more to protect civilians.

As well as the thousands of Tamils who died in the final battles near Mullaitivu, many others are still missing.

The UN human rights office postponed the planned publication of its report in March, after Mr Rajapaksa lost the presidential election to party rival Maithripala Sirisena in January.

Mr Sirisena, who served as a government minister during the final stages of the war, had promised to co-operate with the UN.

The Rajapaksa government held its own commission into what happened in the last years of the war, but critics said it lacked credibility.

The 26-year war left at least 100,000 people dead. There are still no confirmed figures for tens of thousands of civilian deaths in the last months of battle.

Channel 4 and the UN have documented numerous atrocities committed during the war.

One investigation said it was possible up to 40,000 people had been killed in the final five months alone. Others suggest the number of deaths could be even higher.