The government rejected the findings and called for the legal process to be respected.
Anwar began serving a five-year jail sentence in February after the country's top court ruled that he sodomized a former male aide in 2008.
His case has been seen as intended to eliminate any threats to the ruling coalition, whose popularity has eroded in the last two elections.
The UN Working Group on Arbitrary Detention found Anwar was denied a fair trial and his jailing was politically motivated.
Also Read
Anwar's daughter, Nurul Izzah Anwar, said she hopes the government will abide by the group's conclusion.
"I am deeply grateful that the United Nations has called for Anwar's release," said Nurul Izzah, a lawmaker.
"Its strong stance in solidarity with my father sends a clear and unequivocal message to Prime Minister Najib Razak, and ensures that the sharp decline in human rights under his administration will not go unnoticed."
The government reiterated that Anwar's trial was "a criminal, not a political case" as it was brought against him by a private individual.
"It had nothing to do with the government," the prime minister's office said in a statement. "Malaysia has an independent judiciary - with many rulings going against senior government figures - and the government does not have the power or authority to overrule the decisions of the courts."
It urged all parties to respect "the legal process, the judgment of Malaysia's courts and the rights of the victim to seek justice."
The working group is appointed by the UN Human Rights Council and its five current members are from Australia, Benin, Mexico, South Korea and Ukraine.
In the letter, the group also expressed concerns about Anwar's physical and psychological health amid allegations that he is being held in solitary confinement.