KAMPALA - The UN rights office said on Tuesday it was in discussion with Uganda over how to continue its work in the country after the government said it had to leave, a move activists say highlights the country's deteriorating record on civil liberties.

The office was set up in 2006 and has brought to light widespread rights violations by security personnel including torture, illegal detentions and failure by the state to prosecute offenders.

Uganda told the Office of the United Nations High Commissioner for Human Rights (OHCHR) last week that it would not renew the mandate of its office, effectively expelling the rights monitors.

"We are in discussions with the government of Uganda at the highest levels to see what can be done to continue our important work in the country," OHCHR told Reuters in an email.

"A conversation is being scheduled between the UN High Commissioner for Human Rights, Volker Türk, and the President of the Republic of Uganda. The High Commissioner's view is that there should be a U.N. Human Rights presence everywhere."

The government said in a letter to OHCHR that the U.N. presence was no longer necessary because of the progress it had made in developing a domestic capacity to monitor human rights compliance, including the emergence of a strong civil society.

(Reporting by Elias Biryabarema; Editing by Bhargav Acharya and Nick Macfie)