By Lucy Williamson
BBC News, Jakarta
The report will not be easy reading for Ramos Horta or his troops
The UN in East Timor has rejected claims by the country's president that it was slow to act in the aftermath of his shooting earlier this year.
President Ramos-Horta said that international forces had not moved quickly enough to give him medical aid, and to arrest the perpetrators.
But in a confidential report the UN says its response was swift.
Attacks by rebel soldiers in the capital in February left Mr Ramos-Horta seriously wounded.
Prime Minister Xanana Gusmao - also attacked - escaped unharmed.
The report, a leaked copy of which was seen by the BBC, will not be easy reading for East Timor's government.
It admits that better communications could have got international police to the president sooner - but only by four minutes, which it says would not have had any real impact.
What was crucial, it says, was the decision to send a nurse with the police.
The nurse gave Mr Ramos-Horta emergency medical aid as he was lying on the ground - aid which the report suggests may have been critical in saving his life.
There were wider gaps, the UN says, in its response to the second attack on the prime minister: problems reaching his residence, arranging safe evacuation for his family, and securing the crime scenes.
But the most striking flaws it highlights are those in the Timorese forces.
The report says all but four of the soldiers guarding the president's compound deserted their posts when the rebels arrived.
Dili's police force never responded when it was asked to send units.
And the president himself had only two bodyguards with him on his walk that morning - soldiers armed with a single pistol who let him back into the compound while there was shooting.
The UN also denies international forces were slow in pursing those responsible for the attacks. Capturing the rebels, it says, was not a priority for the Timorese government itself.
Instead it says the government focused on securing the city and delayed pursing the perpetrators until two days after the shootings.
The government's accusations put the UN in an awkward position.
And the president has reacted angrily to the report in turn.
The attacks were the most critical episode to face Timor for two years, and the behaviour of its security forces is already a sensitive topic.
There is no hiding the fact they do not come off well in the UN's account of what happened.